Class AmbryReplicaSyncUpManager

  • All Implemented Interfaces:
    com.github.ambry.clustermap.ReplicaSyncUpManager

    public class AmbryReplicaSyncUpManager
    extends java.lang.Object
    implements com.github.ambry.clustermap.ReplicaSyncUpManager
    An implementation of ReplicaSyncUpManager that helps track replica catchup state. To track state of replica that is catching up or being commissioned, this class leverages a CountDownLatch. Every time ReplicaSyncUpManager.initiateBootstrap(ReplicaId) is called, a new latch (with initial value = 1) is created associated with given replica. Any caller that invokes ReplicaSyncUpManager.waitBootstrapCompleted(String) is blocked and wait until corresponding latch counts to zero. External component (i.e. replication manager) is able to call ReplicaSyncUpManager.onBootstrapComplete(ReplicaId) or ReplicaSyncUpManager.onBootstrapError(ReplicaId) to mark sync-up success or failure by counting down the latch. This will unblock caller waiting fot this latch and proceed with subsequent actions.
    • Constructor Summary

      Constructors 
      Constructor Description
      AmbryReplicaSyncUpManager​(com.github.ambry.config.ClusterMapConfig clusterMapConfig)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.util.concurrent.CountDownLatch> getPartitionToDeactivationLatch()  
      java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.util.concurrent.CountDownLatch> getPartitionToDisconnectionLatch()  
      void initiateBootstrap​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void initiateDeactivation​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void initiateDisconnection​(com.github.ambry.clustermap.ReplicaId replicaId)  
      boolean isSyncUpComplete​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void onBootstrapComplete​(com.github.ambry.clustermap.ReplicaId replicaId)
      This method will count down the latch associated with given replica and unblock external service waiting on this latch.
      void onBootstrapError​(com.github.ambry.clustermap.ReplicaId replicaId)
      This method will count down latch and terminates bootstrap.
      void onDeactivationComplete​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void onDeactivationError​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void onDisconnectionComplete​(com.github.ambry.clustermap.ReplicaId replicaId)  
      void onDisconnectionError​(com.github.ambry.clustermap.ReplicaId replicaId)  
      boolean updateLagBetweenReplicas​(com.github.ambry.clustermap.ReplicaId localReplica, com.github.ambry.clustermap.ReplicaId peerReplica, long lagInBytes)  
      void waitBootstrapCompleted​(java.lang.String partitionName)
      The method is blocked on a CountDownLatch until the bootstrap is complete
      void waitDeactivationCompleted​(java.lang.String partitionName)  
      void waitDisconnectionCompleted​(java.lang.String partitionName)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AmbryReplicaSyncUpManager

        public AmbryReplicaSyncUpManager​(com.github.ambry.config.ClusterMapConfig clusterMapConfig)
    • Method Detail

      • initiateBootstrap

        public void initiateBootstrap​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        initiateBootstrap in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • initiateDeactivation

        public void initiateDeactivation​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        initiateDeactivation in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • waitBootstrapCompleted

        public void waitBootstrapCompleted​(java.lang.String partitionName)
                                    throws java.lang.InterruptedException
        The method is blocked on a CountDownLatch until the bootstrap is complete
        Specified by:
        waitBootstrapCompleted in interface com.github.ambry.clustermap.ReplicaSyncUpManager
        Throws:
        java.lang.InterruptedException
      • waitDeactivationCompleted

        public void waitDeactivationCompleted​(java.lang.String partitionName)
                                       throws java.lang.InterruptedException
        Specified by:
        waitDeactivationCompleted in interface com.github.ambry.clustermap.ReplicaSyncUpManager
        Throws:
        java.lang.InterruptedException
      • updateLagBetweenReplicas

        public boolean updateLagBetweenReplicas​(com.github.ambry.clustermap.ReplicaId localReplica,
                                                com.github.ambry.clustermap.ReplicaId peerReplica,
                                                long lagInBytes)
        Specified by:
        updateLagBetweenReplicas in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • isSyncUpComplete

        public boolean isSyncUpComplete​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        isSyncUpComplete in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • onBootstrapComplete

        public void onBootstrapComplete​(com.github.ambry.clustermap.ReplicaId replicaId)
        This method will count down the latch associated with given replica and unblock external service waiting on this latch.
        Specified by:
        onBootstrapComplete in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • onDeactivationComplete

        public void onDeactivationComplete​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        onDeactivationComplete in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • onBootstrapError

        public void onBootstrapError​(com.github.ambry.clustermap.ReplicaId replicaId)
        This method will count down latch and terminates bootstrap.
        Specified by:
        onBootstrapError in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • onDeactivationError

        public void onDeactivationError​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        onDeactivationError in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • initiateDisconnection

        public void initiateDisconnection​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        initiateDisconnection in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • waitDisconnectionCompleted

        public void waitDisconnectionCompleted​(java.lang.String partitionName)
                                        throws java.lang.InterruptedException
        Specified by:
        waitDisconnectionCompleted in interface com.github.ambry.clustermap.ReplicaSyncUpManager
        Throws:
        java.lang.InterruptedException
      • onDisconnectionComplete

        public void onDisconnectionComplete​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        onDisconnectionComplete in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • onDisconnectionError

        public void onDisconnectionError​(com.github.ambry.clustermap.ReplicaId replicaId)
        Specified by:
        onDisconnectionError in interface com.github.ambry.clustermap.ReplicaSyncUpManager
      • getPartitionToDeactivationLatch

        public java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.util.concurrent.CountDownLatch> getPartitionToDeactivationLatch()
        Returns:
        the map whose key is partition name and the value is corresponding deactivation latch.
      • getPartitionToDisconnectionLatch

        public java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.util.concurrent.CountDownLatch> getPartitionToDisconnectionLatch()
        Returns:
        the map whose key is partition name and the value is corresponding disconnection latch.