Package com.github.ambry.clustermap
Class RecoveryTestClusterManager
- java.lang.Object
-
- com.github.ambry.clustermap.RecoveryTestClusterManager
-
- All Implemented Interfaces:
com.github.ambry.clustermap.ClusterMap
,java.lang.AutoCloseable
public class RecoveryTestClusterManager extends java.lang.Object implements com.github.ambry.clustermap.ClusterMap
A cluster manager that is a composed of aStaticClusterManager
and aHelixClusterManager
. It provides a merged view of the static and helix clusters.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.util.List<com.github.ambry.clustermap.PartitionId>
getAllPartitionIds(java.lang.String partitionClass)
Get all partition ids from both the underlyingStaticClusterManager
.com.github.ambry.clustermap.ReplicaId
getBootstrapReplica(java.lang.String partitionIdStr, com.github.ambry.clustermap.DataNodeId dataNodeId)
java.lang.String
getDatacenterName(byte id)
com.github.ambry.clustermap.DataNodeId
getDataNodeId(java.lang.String hostname, int port)
Return theDataNodeId
associated with the given hostname and port in the underlyingStaticClusterManager
.java.util.List<? extends com.github.ambry.clustermap.DataNodeId>
getDataNodeIds()
The list ofDataNodeId
s present in the underlyingHelixClusterManager
byte
getLocalDatacenterId()
com.codahale.metrics.MetricRegistry
getMetricRegistry()
com.github.ambry.clustermap.PartitionId
getPartitionIdFromStream(java.io.InputStream stream)
com.github.ambry.clustermap.PartitionId
getRandomWritablePartition(java.lang.String partitionClass, java.util.List<com.github.ambry.clustermap.PartitionId> partitionsToExclude)
java.util.List<com.github.ambry.clustermap.ReplicaId>
getReplicaIds(com.github.ambry.clustermap.DataNodeId dataNodeId)
Get the list ofReplicaId
s associated with the givenDataNodeId
in the underlyingStaticClusterManager
.org.json.JSONObject
getSnapshot()
java.util.List<com.github.ambry.clustermap.PartitionId>
getWritablePartitionIds(java.lang.String partitionClass)
boolean
hasDatacenter(java.lang.String datacenterName)
Check for existence of the given datacenter from both the static and the helix based cluster managers and update a metric if there is a mismatch.void
onReplicaEvent(com.github.ambry.clustermap.ReplicaId replicaId, com.github.ambry.clustermap.ReplicaEventType event)
Relay the event to both the underlyingStaticClusterManager
and the underlyingHelixClusterManager
.void
registerClusterMapListener(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)
-
-
-
Method Detail
-
getPartitionIdFromStream
public com.github.ambry.clustermap.PartitionId getPartitionIdFromStream(java.io.InputStream stream) throws java.io.IOException
- Specified by:
getPartitionIdFromStream
in interfacecom.github.ambry.clustermap.ClusterMap
- Throws:
java.io.IOException
-
getWritablePartitionIds
public java.util.List<com.github.ambry.clustermap.PartitionId> getWritablePartitionIds(java.lang.String partitionClass)
- Specified by:
getWritablePartitionIds
in interfacecom.github.ambry.clustermap.ClusterMap
-
getRandomWritablePartition
public com.github.ambry.clustermap.PartitionId getRandomWritablePartition(java.lang.String partitionClass, java.util.List<com.github.ambry.clustermap.PartitionId> partitionsToExclude)
- Specified by:
getRandomWritablePartition
in interfacecom.github.ambry.clustermap.ClusterMap
-
getAllPartitionIds
public java.util.List<com.github.ambry.clustermap.PartitionId> getAllPartitionIds(java.lang.String partitionClass)
Get all partition ids from both the underlyingStaticClusterManager
.- Specified by:
getAllPartitionIds
in interfacecom.github.ambry.clustermap.ClusterMap
- Parameters:
partitionClass
- the partition class whose partitions are required. Can benull
- Returns:
- a list of partition ids from the underlying
StaticClusterManager
.
-
hasDatacenter
public boolean hasDatacenter(java.lang.String datacenterName)
Check for existence of the given datacenter from both the static and the helix based cluster managers and update a metric if there is a mismatch.- Specified by:
hasDatacenter
in interfacecom.github.ambry.clustermap.ClusterMap
- Parameters:
datacenterName
- name of datacenter- Returns:
- true if the datacenter exists in the underlying
StaticClusterManager
; false otherwise.
-
getLocalDatacenterId
public byte getLocalDatacenterId()
- Specified by:
getLocalDatacenterId
in interfacecom.github.ambry.clustermap.ClusterMap
-
getDatacenterName
public java.lang.String getDatacenterName(byte id)
- Specified by:
getDatacenterName
in interfacecom.github.ambry.clustermap.ClusterMap
-
getDataNodeId
public com.github.ambry.clustermap.DataNodeId getDataNodeId(java.lang.String hostname, int port)
Return theDataNodeId
associated with the given hostname and port in the underlyingStaticClusterManager
. If not found in static cluster map, then get the same from helix cluster map.- Specified by:
getDataNodeId
in interfacecom.github.ambry.clustermap.ClusterMap
- Parameters:
hostname
- of the DataNodeIdport
- of the DataNodeId- Returns:
- the
DataNodeId
associated with the given hostname and port.
-
getReplicaIds
public java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds(com.github.ambry.clustermap.DataNodeId dataNodeId)
Get the list ofReplicaId
s associated with the givenDataNodeId
in the underlyingStaticClusterManager
. The list ofReplicaId
s is obtained by merging replica lists fromHelixClusterManager
andStaticClusterManager
.- Specified by:
getReplicaIds
in interfacecom.github.ambry.clustermap.ClusterMap
- Parameters:
dataNodeId
- theDataNodeId
for which the replicas are to be listed.- Returns:
- merged list of
ReplicaId
s as present in the underlyingStaticClusterManager
andHelixClusterManager
for the given node.
-
getDataNodeIds
public java.util.List<? extends com.github.ambry.clustermap.DataNodeId> getDataNodeIds()
The list ofDataNodeId
s present in the underlyingHelixClusterManager
- Specified by:
getDataNodeIds
in interfacecom.github.ambry.clustermap.ClusterMap
- Returns:
- the list of
DataNodeId
s present in the underlyingHelixClusterManager
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
- Specified by:
getMetricRegistry
in interfacecom.github.ambry.clustermap.ClusterMap
-
onReplicaEvent
public void onReplicaEvent(com.github.ambry.clustermap.ReplicaId replicaId, com.github.ambry.clustermap.ReplicaEventType event)
Relay the event to both the underlyingStaticClusterManager
and the underlyingHelixClusterManager
.- Specified by:
onReplicaEvent
in interfacecom.github.ambry.clustermap.ClusterMap
- Parameters:
replicaId
- theReplicaId
for which this event has occurred.event
- theReplicaEventType
.
-
getSnapshot
public org.json.JSONObject getSnapshot()
- Specified by:
getSnapshot
in interfacecom.github.ambry.clustermap.ClusterMap
-
getBootstrapReplica
public com.github.ambry.clustermap.ReplicaId getBootstrapReplica(java.lang.String partitionIdStr, com.github.ambry.clustermap.DataNodeId dataNodeId)
- Specified by:
getBootstrapReplica
in interfacecom.github.ambry.clustermap.ClusterMap
-
registerClusterMapListener
public void registerClusterMapListener(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)
- Specified by:
registerClusterMapListener
in interfacecom.github.ambry.clustermap.ClusterMap
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacecom.github.ambry.clustermap.ClusterMap
-
-