Interface ReplicaSyncUpManager


  • public interface ReplicaSyncUpManager
    A class helps check if replicas have synced up. There are two use cases: 1. determine if new added replica has caught up with peers (occurs within BOOTSTRAP -> STANDBY transition) 2. determine peer replicas have caught up with old replica that is being decommissioned; (occurs in STANDBY -> INACTIVE and INACTIVE -> OFFLINE transitions)
    • Method Detail

      • initiateBootstrap

        void initiateBootstrap​(ReplicaId replicaId)
        Initiate bootstrap process if the replica is newly added and needs to catch up with peer ones.
        Parameters:
        replicaId - the replica to bootstrap
      • waitBootstrapCompleted

        void waitBootstrapCompleted​(java.lang.String partitionName)
                             throws java.lang.InterruptedException
        Wait until bootstrap on given replica is complete. until given replica has caught up with enough peer replicas either in local DC or remote DCs
        Parameters:
        partitionName - partition name of replica that in bootstrap state
        Throws:
        java.lang.InterruptedException
      • updateReplicaLagAndCheckSyncStatus

        boolean updateReplicaLagAndCheckSyncStatus​(ReplicaId localReplica,
                                                   ReplicaId peerReplica,
                                                   long lagInBytes,
                                                   ReplicaState targetState)
        Update replica lag (in byte) between two replicas (local and peer replica) and check sync-up status.
        Parameters:
        localReplica - the replica that resides on current node
        peerReplica - the peer replica of local one.
        lagInBytes - replica lag bytes
        targetState - the target state the replica will transit to after sync-up completes.
        Returns:
        whether sync-up is completed by this update. If false, it means either the local replica is not tracked by this manager or the sync-up has not finished yet. For the former case, there are also two cases: (1) the replica has caught up and removed from manager already (2) it is an existing replica that doesn't need catchup.
      • isSyncUpComplete

        boolean isSyncUpComplete​(ReplicaId replicaId)
        Whether given replica has synced up with its peers.
        Parameters:
        replicaId - replica to check
        Returns:
        true if given replica has caught up with peers or peer replicas have synced up with given replica (this occurs when given replica is being decommissioned)
      • onBootstrapComplete

        void onBootstrapComplete​(ReplicaId replicaId)
        Bootstrap on given replica is complete.
        Parameters:
        replicaId - the replica which completes bootstrap.
      • onDeactivationComplete

        void onDeactivationComplete​(ReplicaId replicaId)
        Deactivation on given replica is complete.
        Parameters:
        replicaId - the replica which completes deactivation.
      • onBootstrapError

        void onBootstrapError​(ReplicaId replicaId)
        When exception/error occurs during bootstrap.
        Parameters:
        replicaId - the replica which encounters error.
      • onDeactivationError

        void onDeactivationError​(ReplicaId replicaId)
        When exception/error occurs during deactivation.
        Parameters:
        replicaId - the replica which encounters error.
      • initiateDeactivation

        void initiateDeactivation​(ReplicaId replicaId)
        Initiate deactivation process if the replica should become INACTIVE from STANDBY on current node.
        Parameters:
        replicaId - the replica to deactivate
      • waitDeactivationCompleted

        void waitDeactivationCompleted​(java.lang.String partitionName)
                                throws java.lang.InterruptedException
        Wait until deactivation on given replica is complete.
        Parameters:
        partitionName - the name of replica that is within Standby-To-Inactive transition.
        Throws:
        java.lang.InterruptedException
      • initiateDisconnection

        void initiateDisconnection​(ReplicaId replicaId)
        Initiate disconnection process to stop replica and make it offline. This happens when replica is going to be removed from current node. For Ambry, it disconnection occurs in Inactive-To-Offline transition.
        Parameters:
        replicaId - the ReplicaId to be disconnected.
      • waitDisconnectionCompleted

        void waitDisconnectionCompleted​(java.lang.String partitionName)
                                 throws java.lang.InterruptedException
        Wait until disconnection on given partition is complete.
        Parameters:
        partitionName - partition name of replica that in disconnection process
        Throws:
        java.lang.InterruptedException
      • onDisconnectionComplete

        void onDisconnectionComplete​(ReplicaId replicaId)
        When disconnection completes on given replica and then it becomes offline.
        Parameters:
        replicaId - the ReplicaId on which disconnection completes
      • onDisconnectionError

        void onDisconnectionError​(ReplicaId replicaId)
        When exception/error occurs during disconnection.
        Parameters:
        replicaId - the ReplicaId which encounters error.