Class LocalReplica

    • Constructor Detail

      • LocalReplica

        public LocalReplica​(KetchLeader leader,
                            java.lang.String name,
                            ReplicaConfig cfg)
        Configure a local replica.
        Parameters:
        leader - instance this replica follows.
        name - unique-ish name identifying this replica for debugging.
        cfg - how Ketch should treat the local system.
    • Method Detail

      • describeForLog

        protected java.lang.String describeForLog()
        Get description of this replica for error/debug logging purposes.
        Overrides:
        describeForLog in class KetchReplica
        Returns:
        description of this replica for error/debug logging purposes.
      • initialize

        void initialize​(Repository repo)
                 throws java.io.IOException
        Initializes local replica by reading accepted and committed references.

        Loads accepted and committed references from the reference database of the local replica and stores their current ObjectIds in memory.

        Parameters:
        repo - repository to initialize state from.
        Throws:
        java.io.IOException - cannot read repository state.
      • startPush

        protected void startPush​(ReplicaPushRequest req)
        Begin executing a single push.

        This method must move processing onto another thread. Called with KetchLeader.lock held by caller.

        Specified by:
        startPush in class KetchReplica
        Parameters:
        req - the request to send to the replica.
      • blockingFetch

        protected void blockingFetch​(Repository repo,
                                     ReplicaFetchRequest req)
                              throws java.io.IOException
        Fetch objects from the remote using the calling thread.

        Called without KetchLeader.lock.

        Specified by:
        blockingFetch in class KetchReplica
        Parameters:
        repo - local repository to fetch objects into.
        req - the request to fetch from a replica.
        Throws:
        java.io.IOException - communication with the replica was not possible.
      • checkFailed

        private static void checkFailed​(java.util.List<java.lang.String> failed,
                                        ReceiveCommand cmd)
      • isOnlyTxnNamespace

        private boolean isOnlyTxnNamespace​(java.util.Collection<ReceiveCommand> cmdList)