public class HelixClusterManager
extends java.lang.Object
implements com.github.ambry.clustermap.ClusterMap
ClusterMap
that makes use of Helix to dynamically manage the cluster information.Constructor and Description |
---|
HelixClusterManager(com.github.ambry.config.ClusterMapConfig clusterMapConfig,
java.lang.String instanceName,
HelixFactory helixFactory,
com.codahale.metrics.MetricRegistry metricRegistry)
Instantiate a HelixClusterManager.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Disconnect from the HelixManagers associated with each and every datacenter.
|
java.util.List<com.github.ambry.clustermap.PartitionId> |
getAllPartitionIds(java.lang.String partitionClass) |
com.github.ambry.clustermap.ReplicaId |
getBootstrapReplica(java.lang.String partitionIdStr,
com.github.ambry.clustermap.DataNodeId dataNodeId)
To create bootstrap replica,
HelixClusterManager needs to fetch replica info (i.e. |
java.lang.String |
getDatacenterName(byte id) |
com.github.ambry.clustermap.AmbryDataNode |
getDataNodeId(java.lang.String hostname,
int port) |
java.util.List<com.github.ambry.clustermap.AmbryDataNode> |
getDataNodeIds() |
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.AmbryReplica> |
getReplicaIds(com.github.ambry.clustermap.DataNodeId dataNodeId) |
org.json.JSONObject |
getSnapshot() |
java.util.List<com.github.ambry.clustermap.PartitionId> |
getWritablePartitionIds(java.lang.String partitionClass) |
boolean |
hasDatacenter(java.lang.String datacenterName) |
void |
onReplicaEvent(com.github.ambry.clustermap.ReplicaId replicaId,
com.github.ambry.clustermap.ReplicaEventType event) |
public HelixClusterManager(com.github.ambry.config.ClusterMapConfig clusterMapConfig, java.lang.String instanceName, HelixFactory helixFactory, com.codahale.metrics.MetricRegistry metricRegistry) throws java.io.IOException
clusterMapConfig
- the ClusterMapConfig
associated with this manager.instanceName
- the String representation of the instance associated with this manager.helixFactory
- the factory class to construct and get a reference to a HelixManager
.metricRegistry
- the registry of metric instances associated with this manager.java.io.IOException
- if there is an error in parsing the clusterMapConfig or in connecting with the associated
remote Zookeeper services.public boolean hasDatacenter(java.lang.String datacenterName)
hasDatacenter
in interface com.github.ambry.clustermap.ClusterMap
public byte getLocalDatacenterId()
getLocalDatacenterId
in interface com.github.ambry.clustermap.ClusterMap
public java.lang.String getDatacenterName(byte id)
getDatacenterName
in interface com.github.ambry.clustermap.ClusterMap
public com.github.ambry.clustermap.AmbryDataNode getDataNodeId(java.lang.String hostname, int port)
getDataNodeId
in interface com.github.ambry.clustermap.ClusterMap
public java.util.List<com.github.ambry.clustermap.AmbryReplica> getReplicaIds(com.github.ambry.clustermap.DataNodeId dataNodeId)
getReplicaIds
in interface com.github.ambry.clustermap.ClusterMap
public java.util.List<com.github.ambry.clustermap.AmbryDataNode> getDataNodeIds()
getDataNodeIds
in interface com.github.ambry.clustermap.ClusterMap
public com.codahale.metrics.MetricRegistry getMetricRegistry()
getMetricRegistry
in interface com.github.ambry.clustermap.ClusterMap
public void onReplicaEvent(com.github.ambry.clustermap.ReplicaId replicaId, com.github.ambry.clustermap.ReplicaEventType event)
onReplicaEvent
in interface com.github.ambry.clustermap.ClusterMap
public org.json.JSONObject getSnapshot()
getSnapshot
in interface com.github.ambry.clustermap.ClusterMap
public com.github.ambry.clustermap.PartitionId getPartitionIdFromStream(java.io.InputStream stream) throws java.io.IOException
getPartitionIdFromStream
in interface com.github.ambry.clustermap.ClusterMap
java.io.IOException
public java.util.List<com.github.ambry.clustermap.PartitionId> getWritablePartitionIds(java.lang.String partitionClass)
getWritablePartitionIds
in interface com.github.ambry.clustermap.ClusterMap
public com.github.ambry.clustermap.PartitionId getRandomWritablePartition(java.lang.String partitionClass, java.util.List<com.github.ambry.clustermap.PartitionId> partitionsToExclude)
getRandomWritablePartition
in interface com.github.ambry.clustermap.ClusterMap
public java.util.List<com.github.ambry.clustermap.PartitionId> getAllPartitionIds(java.lang.String partitionClass)
getAllPartitionIds
in interface com.github.ambry.clustermap.ClusterMap
public com.github.ambry.clustermap.ReplicaId getBootstrapReplica(java.lang.String partitionIdStr, com.github.ambry.clustermap.DataNodeId dataNodeId)
HelixClusterManager
needs to fetch replica info (i.e. capacity, mount path)
from Helix PropertyStore. This method looks up the ZNode in local datacenter and does some validation. Right now,
HelixClusterManager
supports getting bootstrap replica of new partition but it doesn't support getting replica
residing on hosts that are not present in clustermap.
The ZNRecord of REPLICA_ADDITION_ZNODE has following format in mapFields.
"mapFields": { "1": { "replicaCapacityInBytes": 107374182400, "partitionClass": "max-replicas-all-datacenters", "localhost1_17088": "/tmp/c/1", "localhost2_17088": "/tmp/d/1" }, "2": { "replicaCapacityInBytes": 107374182400, "partitionClass": "max-replicas-all-datacenters", "localhost3_17088": "/tmp/e/1" } }In above example, two bootstrap replicas of partition[1] will be added to localhost1 and localhost2 respectively. The host name is followed by mount path on which the bootstrap replica should be placed.
getBootstrapReplica
in interface com.github.ambry.clustermap.ClusterMap
public void close()
close
in interface com.github.ambry.clustermap.ClusterMap
close
in interface java.lang.AutoCloseable