Package com.github.ambry.clustermap
Class AmbryReplicaSyncUpManager
- java.lang.Object
-
- com.github.ambry.clustermap.AmbryReplicaSyncUpManager
-
- All Implemented Interfaces:
com.github.ambry.clustermap.ReplicaSyncUpManager
public class AmbryReplicaSyncUpManager extends java.lang.Object implements com.github.ambry.clustermap.ReplicaSyncUpManager
An implementation ofReplicaSyncUpManager
that helps track replica catchup state. To track state of replica that is catching up or being commissioned, this class leverages aCountDownLatch
. Every timeReplicaSyncUpManager.initiateBootstrap(ReplicaId)
is called, a new latch (with initial value = 1) is created associated with given replica. Any caller that invokesReplicaSyncUpManager.waitBootstrapCompleted(String)
is blocked and wait until corresponding latch counts to zero. External component (i.e. replication manager) is able to callReplicaSyncUpManager.onBootstrapComplete(ReplicaId)
orReplicaSyncUpManager.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
updateReplicaLagAndCheckSyncStatus(com.github.ambry.clustermap.ReplicaId localReplica, com.github.ambry.clustermap.ReplicaId peerReplica, long lagInBytes, com.github.ambry.clustermap.ReplicaState targetState)
void
waitBootstrapCompleted(java.lang.String partitionName)
The method is blocked on aCountDownLatch
until the bootstrap is completevoid
waitDeactivationCompleted(java.lang.String partitionName)
void
waitDisconnectionCompleted(java.lang.String partitionName)
-
-
-
Method Detail
-
initiateBootstrap
public void initiateBootstrap(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
initiateBootstrap
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
initiateDeactivation
public void initiateDeactivation(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
initiateDeactivation
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
initiateDisconnection
public void initiateDisconnection(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
initiateDisconnection
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
waitBootstrapCompleted
public void waitBootstrapCompleted(java.lang.String partitionName) throws java.lang.InterruptedException
The method is blocked on aCountDownLatch
until the bootstrap is complete- Specified by:
waitBootstrapCompleted
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
- Throws:
java.lang.InterruptedException
-
waitDeactivationCompleted
public void waitDeactivationCompleted(java.lang.String partitionName) throws java.lang.InterruptedException
- Specified by:
waitDeactivationCompleted
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
- Throws:
java.lang.InterruptedException
-
waitDisconnectionCompleted
public void waitDisconnectionCompleted(java.lang.String partitionName) throws java.lang.InterruptedException
- Specified by:
waitDisconnectionCompleted
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
- Throws:
java.lang.InterruptedException
-
updateReplicaLagAndCheckSyncStatus
public boolean updateReplicaLagAndCheckSyncStatus(com.github.ambry.clustermap.ReplicaId localReplica, com.github.ambry.clustermap.ReplicaId peerReplica, long lagInBytes, com.github.ambry.clustermap.ReplicaState targetState)
- Specified by:
updateReplicaLagAndCheckSyncStatus
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
isSyncUpComplete
public boolean isSyncUpComplete(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
isSyncUpComplete
in interfacecom.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 interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
onDeactivationComplete
public void onDeactivationComplete(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
onDeactivationComplete
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
onDisconnectionComplete
public void onDisconnectionComplete(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
onDisconnectionComplete
in interfacecom.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 interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
onDeactivationError
public void onDeactivationError(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
onDeactivationError
in interfacecom.github.ambry.clustermap.ReplicaSyncUpManager
-
onDisconnectionError
public void onDisconnectionError(com.github.ambry.clustermap.ReplicaId replicaId)
- Specified by:
onDisconnectionError
in interfacecom.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.
-
-