Package com.github.ambry.clustermap
Interface ClusterChangeHandler
-
- All Known Implementing Classes:
DynamicClusterChangeHandler
,SimpleClusterChangeHandler
public interface ClusterChangeHandler
General handler that handles any resource or state changes in cluster. It exposes API(s) for cluster manager to access up-to-date cluster info for a data center. Each data center has its ownClusterChangeHandler
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<com.github.ambry.clustermap.AmbryDataNode>
getAllDataNodes()
com.github.ambry.clustermap.AmbryDataNode
getDataNode(java.lang.String instanceName)
Get ambry data node associated with given instance name.java.util.Map<com.github.ambry.clustermap.AmbryDataNode,java.util.Set<com.github.ambry.clustermap.AmbryDisk>>
getDataNodeToDisksMap()
java.util.Set<com.github.ambry.clustermap.AmbryDisk>
getDisks(com.github.ambry.clustermap.AmbryDataNode ambryDataNode)
Get all disks belong to given data node.long
getErrorCount()
java.util.Map<java.lang.String,java.lang.String>
getPartitionToResourceMap()
AmbryReplica
getReplicaId(com.github.ambry.clustermap.AmbryDataNode ambryDataNode, java.lang.String partitionName)
GetAmbryReplica
on given node that belongs to specified partition.java.util.List<AmbryReplica>
getReplicaIds(com.github.ambry.clustermap.AmbryDataNode ambryDataNode)
Get all replicas on given node.java.util.stream.Stream<AmbryReplica>
getReplicaIdsByState(AmbryPartition partition, com.github.ambry.clustermap.ReplicaState state)
Get replicas of given partition from this datacenter that are in required statevoid
registerClusterMapListener(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)
Register a listener of cluster map for any changes.
-
-
-
Method Detail
-
registerClusterMapListener
void registerClusterMapListener(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)
Register a listener of cluster map for any changes.- Parameters:
clusterMapChangeListener
- theClusterMapChangeListener
to add.
-
getReplicaIdsByState
java.util.stream.Stream<AmbryReplica> getReplicaIdsByState(AmbryPartition partition, com.github.ambry.clustermap.ReplicaState state)
Get replicas of given partition from this datacenter that are in required state- Parameters:
partition
- thePartitionId
for which to get the list of replicas.state
-ReplicaState
associated with replica- Returns:
- the
ReplicaId
s satisfying requirements.
-
getDataNodeToDisksMap
java.util.Map<com.github.ambry.clustermap.AmbryDataNode,java.util.Set<com.github.ambry.clustermap.AmbryDisk>> getDataNodeToDisksMap()
- Returns:
- a map from ambry data node to its disks.
-
getDataNode
com.github.ambry.clustermap.AmbryDataNode getDataNode(java.lang.String instanceName)
Get ambry data node associated with given instance name.- Parameters:
instanceName
- associated with ambry node.- Returns:
- requested
AmbryDataNode
-
getReplicaId
AmbryReplica getReplicaId(com.github.ambry.clustermap.AmbryDataNode ambryDataNode, java.lang.String partitionName)
GetAmbryReplica
on given node that belongs to specified partition.- Parameters:
ambryDataNode
- the node on which the replica resides.partitionName
- name of partition which the replica belongs to.- Returns:
- requested
AmbryReplica
-
getReplicaIds
java.util.List<AmbryReplica> getReplicaIds(com.github.ambry.clustermap.AmbryDataNode ambryDataNode)
Get all replicas on given node.- Parameters:
ambryDataNode
- the node on which replicas reside- Returns:
- a list of
AmbryReplica
on given node.
-
getAllDataNodes
java.util.List<com.github.ambry.clustermap.AmbryDataNode> getAllDataNodes()
- Returns:
- all
AmbryDataNode
tracked by thisClusterChangeHandler
-
getDisks
java.util.Set<com.github.ambry.clustermap.AmbryDisk> getDisks(com.github.ambry.clustermap.AmbryDataNode ambryDataNode)
Get all disks belong to given data node.- Parameters:
ambryDataNode
- the node which the disks belong to.- Returns:
- a set of
AmbryDisk
that belongs to given node.
-
getPartitionToResourceMap
java.util.Map<java.lang.String,java.lang.String> getPartitionToResourceMap()
- Returns:
- a map from partition name to its corresponding resource name in this
ClusterChangeHandler
.
-
getErrorCount
long getErrorCount()
- Returns:
- number of errors occurred during handling cluster changes.
-
-