Class 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 of ClusterParticipant that registers as a participant to a Helix cluster.
    • Field Detail

      • participantMetrics

        protected final com.github.ambry.clustermap.HelixParticipantMetrics participantMetrics
    • 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 - the ClusterMapConfig associated with this participant.
        helixFactory - the HelixFactory to use to get the HelixManager.
        metricRegistry - the MetricRegistry to instantiate HelixParticipantMetrics.
        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 interface com.github.ambry.clustermap.ClusterParticipant
      • participate

        public void participate​(java.util.List<com.github.ambry.server.AmbryHealthReport> ambryHealthReports,
                                com.github.ambry.commons.Callback<com.github.ambry.server.StatsSnapshot> callback)
                         throws java.io.IOException
        Initiate the participation by registering via the HelixManager as a participant to the associated Helix cluster.
        Specified by:
        participate in interface com.github.ambry.clustermap.ClusterParticipant
        Parameters:
        ambryHealthReports - List of AmbryHealthReport to be registered to the participant.
        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 interface com.github.ambry.clustermap.ClusterParticipant
      • setReplicaSealedState

        public boolean setReplicaSealedState​(com.github.ambry.clustermap.ReplicaId replicaId,
                                             boolean isSealed)
        Specified by:
        setReplicaSealedState in interface com.github.ambry.clustermap.ClusterParticipant
      • setReplicaStoppedState

        public boolean setReplicaStoppedState​(java.util.List<com.github.ambry.clustermap.ReplicaId> replicaIds,
                                              boolean markStop)
        Specified by:
        setReplicaStoppedState in interface com.github.ambry.clustermap.ClusterParticipant
      • close

        public void close()
        Disconnect from the HelixManager.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface com.github.ambry.clustermap.ClusterParticipant
      • getSealedReplicas

        public java.util.List<java.lang.String> getSealedReplicas()
        Specified by:
        getSealedReplicas in interface com.github.ambry.clustermap.ClusterParticipant
        Returns:
        list of sealed replicas from HelixAdmin.
      • getStoppedReplicas

        public java.util.List<java.lang.String> getStoppedReplicas()
        Specified by:
        getStoppedReplicas in interface com.github.ambry.clustermap.ClusterParticipant
        Returns:
        list of stopped replicas from HelixAdmin
      • getDisabledReplicas

        public java.util.List<java.lang.String> getDisabledReplicas()
        Specified by:
        getDisabledReplicas in interface com.github.ambry.clustermap.ClusterParticipant
      • getReplicaSyncUpManager

        public com.github.ambry.clustermap.ReplicaSyncUpManager getReplicaSyncUpManager()
        Specified by:
        getReplicaSyncUpManager in interface com.github.ambry.clustermap.ClusterParticipant
      • updateDataNodeInfoInCluster

        public boolean updateDataNodeInfoInCluster​(com.github.ambry.clustermap.ReplicaId replicaId,
                                                   boolean shouldExist)
        Specified by:
        updateDataNodeInfoInCluster in interface com.github.ambry.clustermap.ClusterParticipant
      • getPartitionStateChangeListeners

        public java.util.Map<com.github.ambry.clustermap.StateModelListenerType,​com.github.ambry.clustermap.PartitionStateChangeListener> getPartitionStateChangeListeners()
        Specified by:
        getPartitionStateChangeListeners in interface com.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 interface com.github.ambry.clustermap.ClusterParticipant
      • resetPartitionState

        public boolean resetPartitionState​(java.lang.String partitionName)
        Specified by:
        resetPartitionState in interface com.github.ambry.clustermap.ClusterParticipant
      • supportsStateChanges

        public boolean supportsStateChanges()
        Specified by:
        supportsStateChanges in interface com.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 interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeStandbyFromBootstrap

        public void onPartitionBecomeStandbyFromBootstrap​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeStandbyFromBootstrap in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeLeaderFromStandby

        public void onPartitionBecomeLeaderFromStandby​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeLeaderFromStandby in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeStandbyFromLeader

        public void onPartitionBecomeStandbyFromLeader​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeStandbyFromLeader in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeInactiveFromStandby

        public void onPartitionBecomeInactiveFromStandby​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeInactiveFromStandby in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeOfflineFromInactive

        public void onPartitionBecomeOfflineFromInactive​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeOfflineFromInactive in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeDroppedFromOffline

        public void onPartitionBecomeDroppedFromOffline​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeDroppedFromOffline in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeDroppedFromError

        public void onPartitionBecomeDroppedFromError​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeDroppedFromError in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onPartitionBecomeOfflineFromError

        public void onPartitionBecomeOfflineFromError​(java.lang.String partitionName)
        Specified by:
        onPartitionBecomeOfflineFromError in interface com.github.ambry.clustermap.PartitionStateChangeListener
      • onReset

        public void onReset​(java.lang.String partitionName)
        Specified by:
        onReset in interface com.github.ambry.clustermap.PartitionStateChangeListener