Package com.github.ambry.clustermap
Class HelixParticipant
- java.lang.Object
-
- com.github.ambry.clustermap.HelixParticipant
-
- All Implemented Interfaces:
com.github.ambry.clustermap.ClusterParticipant
,com.github.ambry.clustermap.PartitionStateChangeListener
,java.lang.AutoCloseable
public class HelixParticipant extends java.lang.Object implements com.github.ambry.clustermap.ClusterParticipant, com.github.ambry.clustermap.PartitionStateChangeListener
An implementation ofClusterParticipant
that registers as a participant to a Helix cluster.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.github.ambry.clustermap.HelixParticipantMetrics
participantMetrics
-
Constructor Summary
Constructors Constructor Description HelixParticipant(com.github.ambry.config.ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, com.codahale.metrics.MetricRegistry metricRegistry, java.lang.String zkConnectStr, boolean isSoleParticipant)
Instantiate a HelixParticipant.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Disconnect from theHelixManager
.java.util.List<java.lang.String>
getDisabledReplicas()
org.apache.helix.HelixAdmin
getHelixAdmin()
Exposed for testingjava.util.Map<com.github.ambry.clustermap.StateModelListenerType,com.github.ambry.clustermap.PartitionStateChangeListener>
getPartitionStateChangeListeners()
com.github.ambry.clustermap.ReplicaSyncUpManager
getReplicaSyncUpManager()
java.util.List<java.lang.String>
getSealedReplicas()
java.util.List<java.lang.String>
getStoppedReplicas()
protected void
markDisablePartitionComplete()
Mark disablePartitionsComplete = true, this is exposed for testing only.void
onPartitionBecomeBootstrapFromOffline(java.lang.String partitionName)
void
onPartitionBecomeDroppedFromError(java.lang.String partitionName)
void
onPartitionBecomeDroppedFromOffline(java.lang.String partitionName)
void
onPartitionBecomeInactiveFromStandby(java.lang.String partitionName)
void
onPartitionBecomeLeaderFromStandby(java.lang.String partitionName)
void
onPartitionBecomeOfflineFromError(java.lang.String partitionName)
void
onPartitionBecomeOfflineFromInactive(java.lang.String partitionName)
void
onPartitionBecomeStandbyFromBootstrap(java.lang.String partitionName)
void
onPartitionBecomeStandbyFromLeader(java.lang.String partitionName)
void
onReset(java.lang.String partitionName)
void
participate(java.util.List<com.github.ambry.server.AmbryHealthReport> ambryHealthReports, com.github.ambry.server.AccountStatsStore accountStatsStore, com.github.ambry.commons.Callback<com.github.ambry.server.StatsSnapshot> callback)
Initiate the participation by registering via theHelixManager
as a participant to the associated Helix cluster.void
registerPartitionStateChangeListener(com.github.ambry.clustermap.StateModelListenerType listenerType, com.github.ambry.clustermap.PartitionStateChangeListener partitionStateChangeListener)
boolean
resetPartitionState(java.lang.String partitionName)
void
setInitialLocalPartitions(java.util.Collection<java.lang.String> localPartitions)
void
setReplicaDisabledState(com.github.ambry.clustermap.ReplicaId replicaId, boolean disable)
boolean
setReplicaSealedState(com.github.ambry.clustermap.ReplicaId replicaId, boolean isSealed)
boolean
setReplicaStoppedState(java.util.List<com.github.ambry.clustermap.ReplicaId> replicaIds, boolean markStop)
boolean
supportsStateChanges()
boolean
updateDataNodeInfoInCluster(com.github.ambry.clustermap.ReplicaId replicaId, boolean shouldExist)
-
-
-
Constructor Detail
-
HelixParticipant
public HelixParticipant(com.github.ambry.config.ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, com.codahale.metrics.MetricRegistry metricRegistry, java.lang.String zkConnectStr, boolean isSoleParticipant)
Instantiate a HelixParticipant.- Parameters:
clusterMapConfig
- theClusterMapConfig
associated with this participant.helixFactory
- theHelixFactory
to use to get theHelixManager
.metricRegistry
- theMetricRegistry
to instantiateHelixParticipantMetrics
.zkConnectStr
- the address identifying the zk service which this participant interacts with.isSoleParticipant
- whether this is the sole participant on current node.
-
-
Method Detail
-
setInitialLocalPartitions
public void setInitialLocalPartitions(java.util.Collection<java.lang.String> localPartitions)
- Specified by:
setInitialLocalPartitions
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
participate
public void participate(java.util.List<com.github.ambry.server.AmbryHealthReport> ambryHealthReports, com.github.ambry.server.AccountStatsStore accountStatsStore, com.github.ambry.commons.Callback<com.github.ambry.server.StatsSnapshot> callback) throws java.io.IOException
Initiate the participation by registering via theHelixManager
as a participant to the associated Helix cluster.- Specified by:
participate
in interfacecom.github.ambry.clustermap.ClusterParticipant
- 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
- if there is an error connecting to the Helix cluster.
-
registerPartitionStateChangeListener
public void registerPartitionStateChangeListener(com.github.ambry.clustermap.StateModelListenerType listenerType, com.github.ambry.clustermap.PartitionStateChangeListener partitionStateChangeListener)
- Specified by:
registerPartitionStateChangeListener
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
setReplicaSealedState
public boolean setReplicaSealedState(com.github.ambry.clustermap.ReplicaId replicaId, boolean isSealed)
- Specified by:
setReplicaSealedState
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
setReplicaStoppedState
public boolean setReplicaStoppedState(java.util.List<com.github.ambry.clustermap.ReplicaId> replicaIds, boolean markStop)
- Specified by:
setReplicaStoppedState
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
close
public void close()
Disconnect from theHelixManager
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
getSealedReplicas
public java.util.List<java.lang.String> getSealedReplicas()
- Specified by:
getSealedReplicas
in interfacecom.github.ambry.clustermap.ClusterParticipant
- Returns:
- list of sealed replicas from HelixAdmin.
-
getStoppedReplicas
public java.util.List<java.lang.String> getStoppedReplicas()
- Specified by:
getStoppedReplicas
in interfacecom.github.ambry.clustermap.ClusterParticipant
- Returns:
- list of stopped replicas from HelixAdmin
-
getDisabledReplicas
public java.util.List<java.lang.String> getDisabledReplicas()
- Specified by:
getDisabledReplicas
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
getReplicaSyncUpManager
public com.github.ambry.clustermap.ReplicaSyncUpManager getReplicaSyncUpManager()
- Specified by:
getReplicaSyncUpManager
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
updateDataNodeInfoInCluster
public boolean updateDataNodeInfoInCluster(com.github.ambry.clustermap.ReplicaId replicaId, boolean shouldExist)
- Specified by:
updateDataNodeInfoInCluster
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
getPartitionStateChangeListeners
public java.util.Map<com.github.ambry.clustermap.StateModelListenerType,com.github.ambry.clustermap.PartitionStateChangeListener> getPartitionStateChangeListeners()
- Specified by:
getPartitionStateChangeListeners
in interfacecom.github.ambry.clustermap.ClusterParticipant
- Returns:
- a snapshot of registered state change listeners.
-
setReplicaDisabledState
public void setReplicaDisabledState(com.github.ambry.clustermap.ReplicaId replicaId, boolean disable)
- Specified by:
setReplicaDisabledState
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
resetPartitionState
public boolean resetPartitionState(java.lang.String partitionName)
- Specified by:
resetPartitionState
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
supportsStateChanges
public boolean supportsStateChanges()
- Specified by:
supportsStateChanges
in interfacecom.github.ambry.clustermap.ClusterParticipant
-
getHelixAdmin
public org.apache.helix.HelixAdmin getHelixAdmin()
Exposed for testing- Returns:
HelixAdmin
that manages current data node.
-
markDisablePartitionComplete
protected void markDisablePartitionComplete()
Mark disablePartitionsComplete = true, this is exposed for testing only.
-
onPartitionBecomeBootstrapFromOffline
public void onPartitionBecomeBootstrapFromOffline(java.lang.String partitionName)
- Specified by:
onPartitionBecomeBootstrapFromOffline
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeStandbyFromBootstrap
public void onPartitionBecomeStandbyFromBootstrap(java.lang.String partitionName)
- Specified by:
onPartitionBecomeStandbyFromBootstrap
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeLeaderFromStandby
public void onPartitionBecomeLeaderFromStandby(java.lang.String partitionName)
- Specified by:
onPartitionBecomeLeaderFromStandby
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeStandbyFromLeader
public void onPartitionBecomeStandbyFromLeader(java.lang.String partitionName)
- Specified by:
onPartitionBecomeStandbyFromLeader
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeInactiveFromStandby
public void onPartitionBecomeInactiveFromStandby(java.lang.String partitionName)
- Specified by:
onPartitionBecomeInactiveFromStandby
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeOfflineFromInactive
public void onPartitionBecomeOfflineFromInactive(java.lang.String partitionName)
- Specified by:
onPartitionBecomeOfflineFromInactive
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeDroppedFromOffline
public void onPartitionBecomeDroppedFromOffline(java.lang.String partitionName)
- Specified by:
onPartitionBecomeDroppedFromOffline
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeDroppedFromError
public void onPartitionBecomeDroppedFromError(java.lang.String partitionName)
- Specified by:
onPartitionBecomeDroppedFromError
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onPartitionBecomeOfflineFromError
public void onPartitionBecomeOfflineFromError(java.lang.String partitionName)
- Specified by:
onPartitionBecomeOfflineFromError
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
onReset
public void onReset(java.lang.String partitionName)
- Specified by:
onReset
in interfacecom.github.ambry.clustermap.PartitionStateChangeListener
-
-