Package com.github.ambry.clustermap
Interface ClusterParticipant
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface ClusterParticipant extends java.lang.AutoCloseable
A ClusterParticipant is a component that makes up the Ambry cluster.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Terminate the participant.default java.util.List<java.lang.String>
getDisabledReplicas()
Get a list of replicas that have been disabled.java.util.Map<StateModelListenerType,PartitionStateChangeListener>
getPartitionStateChangeListeners()
ReplicaSyncUpManager
getReplicaSyncUpManager()
Gets theReplicaSyncUpManager
object.java.util.List<java.lang.String>
getSealedReplicas()
Get a list of replicas that are marked as sealed (read-only).java.util.List<java.lang.String>
getStoppedReplicas()
Get a list of replicas that are marked as stopped.void
participate(java.util.List<AmbryHealthReport> ambryHealthReports, AccountStatsStore accountStatsStore, Callback<StatsSnapshot> callback)
Initiate the participation of cluster participant.void
registerPartitionStateChangeListener(StateModelListenerType listenerType, PartitionStateChangeListener partitionStateChangeListener)
Register a listener for leadership changes in partitions of this node.default boolean
resetPartitionState(java.lang.String partitionName)
Reset given partition to initial state.default void
setInitialLocalPartitions(java.util.Collection<java.lang.String> localPartitions)
Set initial local partitions that the cluster participant hosts.default void
setReplicaDisabledState(ReplicaId replicaId, boolean disable)
Set or reset the disabled state of the given replicaboolean
setReplicaSealedState(ReplicaId replicaId, boolean isSealed)
Set or reset the sealed state of the given replica.boolean
setReplicaStoppedState(java.util.List<ReplicaId> replicaIds, boolean markStop)
Set or reset the stopped state of the given replica.default boolean
supportsStateChanges()
boolean
updateDataNodeInfoInCluster(ReplicaId replicaId, boolean shouldExist)
Update disk/replica infos associated with current data node in cluster (this occurs when replica addition/removal on current node is complete and local changes will be broadcast to all listeners in this cluster)
-
-
-
Method Detail
-
participate
void participate(java.util.List<AmbryHealthReport> ambryHealthReports, AccountStatsStore accountStatsStore, Callback<StatsSnapshot> callback) throws java.io.IOException
Initiate the participation of cluster participant.- Parameters:
ambryHealthReports
-List
ofAmbryHealthReport
to be registered to the participant.accountStatsStore
- TheAccountStatsStore
to retrieve and store container stats.callback
- a callback which will be invoked when the aggregation report has been generated successfully.- Throws:
java.io.IOException
-
setReplicaSealedState
boolean setReplicaSealedState(ReplicaId replicaId, boolean isSealed)
Set or reset the sealed state of the given replica.- Parameters:
replicaId
- theReplicaId
whose sealed state will be updated.isSealed
- if true, the replica will be marked as sealed; otherwise it will be marked as read-write.- Returns:
true
if set replica sealed state was successful.false
if not.
-
setReplicaStoppedState
boolean setReplicaStoppedState(java.util.List<ReplicaId> replicaIds, boolean markStop)
Set or reset the stopped state of the given replica.- Parameters:
replicaIds
- a list of replicas whose stopped state will be updatedmarkStop
- if true, the replica will be marked as stopped; otherwise it will be marked as started.- Returns:
true
if set replica stopped state was successful.false
if not.
-
setReplicaDisabledState
default void setReplicaDisabledState(ReplicaId replicaId, boolean disable)
Set or reset the disabled state of the given replica- Parameters:
replicaId
- theReplicaId
whose disabled state will be updated.
-
getSealedReplicas
java.util.List<java.lang.String> getSealedReplicas()
Get a list of replicas that are marked as sealed (read-only).- Returns:
- a list of all sealed replicas.
-
getStoppedReplicas
java.util.List<java.lang.String> getStoppedReplicas()
Get a list of replicas that are marked as stopped.- Returns:
- a list of all stopped replicas.
-
getDisabledReplicas
default java.util.List<java.lang.String> getDisabledReplicas()
Get a list of replicas that have been disabled.- Returns:
- a list of all disabled replicas.
-
registerPartitionStateChangeListener
void registerPartitionStateChangeListener(StateModelListenerType listenerType, PartitionStateChangeListener partitionStateChangeListener)
Register a listener for leadership changes in partitions of this node.- Parameters:
listenerType
- the type of listener, which is defined inStateModelListenerType
partitionStateChangeListener
- listener to register.
-
getReplicaSyncUpManager
ReplicaSyncUpManager getReplicaSyncUpManager()
Gets theReplicaSyncUpManager
object.- Returns:
ReplicaSyncUpManager
that is used to determine new replica has caught up with peers or peer replicas have caught up with old replica that is being decommissioned.
-
updateDataNodeInfoInCluster
boolean updateDataNodeInfoInCluster(ReplicaId replicaId, boolean shouldExist)
Update disk/replica infos associated with current data node in cluster (this occurs when replica addition/removal on current node is complete and local changes will be broadcast to all listeners in this cluster)- Parameters:
replicaId
- theReplicaId
whose info should be updated on current nodeshouldExist
- Whether the replica info should exist or not. Whentrue
, replica info will be added if it is missing in current node info. Whenfalse
, replica info will be removed if present.- Returns:
- if
true
, node info is successfully updated.false
otherwise.
-
setInitialLocalPartitions
default void setInitialLocalPartitions(java.util.Collection<java.lang.String> localPartitions)
Set initial local partitions that the cluster participant hosts.- Parameters:
localPartitions
- a collection of initial local partitions.
-
resetPartitionState
default boolean resetPartitionState(java.lang.String partitionName)
Reset given partition to initial state.- Parameters:
partitionName
- the partition to reset.- Returns:
- whether reset operation succeeded or not.
-
getPartitionStateChangeListeners
java.util.Map<StateModelListenerType,PartitionStateChangeListener> getPartitionStateChangeListeners()
- Returns:
- a map of registered state change listeners (if there are any) in this cluster participant.
-
supportsStateChanges
default boolean supportsStateChanges()
- Returns:
true
if this participant supports dynamic partition state changes.
-
close
void close()
Terminate the participant.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-