Class VeniceControllerStateModel

java.lang.Object
org.apache.helix.participant.statemachine.StateModel
com.linkedin.venice.controller.VeniceControllerStateModel

public class VeniceControllerStateModel extends org.apache.helix.participant.statemachine.StateModel
State model used to handle the change of leader-standby relationship for controllers.

This class should extend DistClusterControllerStateModel, but we need a helix manager to to the essential initialization but it is the private member of DistClusterControllerStateModel, so we can't get it in sub-class. So we don't extend it right now. //TODO Will ask Helix team to modify the visibility.

  • Constructor Details

  • Method Details

    • isLeader

      public boolean isLeader()
      Test if current state is HelixState.LEADER_STATE.
      Returns:
      true if current state is HelixState.LEADER_STATE; false otherwise.
    • updateState

      public boolean updateState(String newState)
      This runs after the state transition occurred.
      Overrides:
      updateState in class org.apache.helix.participant.statemachine.StateModel
    • onBecomeLeaderFromStandby

      public void onBecomeLeaderFromStandby(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.STANDBY_STATE to HelixState.LEADER_STATE.
    • onBecomeStandbyFromLeader

      public void onBecomeStandbyFromLeader(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.LEADER_STATE to HelixState.STANDBY_STATE.
    • onBecomeOfflineFromStandby

      public void onBecomeOfflineFromStandby(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.STANDBY_STATE to HelixState.OFFLINE_STATE.
    • onBecomeStandbyFromOffline

      public void onBecomeStandbyFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.OFFLINE_STATE to HelixState.STANDBY_STATE.
    • onBecomeDroppedFromOffline

      public void onBecomeDroppedFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.OFFLINE_STATE to HelixState.DROPPED_STATE.
    • onBecomeDroppedFromError

      public void onBecomeDroppedFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.ERROR_STATE to HelixState.DROPPED_STATE.
      Overrides:
      onBecomeDroppedFromError in class org.apache.helix.participant.statemachine.StateModel
    • onBecomingOfflineFromError

      public void onBecomingOfflineFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      A callback for Helix state transition from HelixState.ERROR_STATE to HelixState.OFFLINE_STATE.
    • rollbackOnError

      public void rollbackOnError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context, org.apache.helix.participant.statemachine.StateTransitionError error)
      Called when error occurs in state transition.
      Overrides:
      rollbackOnError in class org.apache.helix.participant.statemachine.StateModel
    • reset

      public void reset()
      Called when the state model is reset.
      Overrides:
      reset in class org.apache.helix.participant.statemachine.StateModel
    • getVeniceClusterNameFromPartitionName

      protected static String getVeniceClusterNameFromPartitionName(String partitionName)
      Get the regular Venice cluster name after removing the suffix PARTITION_SUFFIX.
      Parameters:
      partitionName - controller partition name.
      Returns:
      Venice cluster name.
    • getPartitionNameFromVeniceClusterName

      protected static String getPartitionNameFromVeniceClusterName(String veniceClusterName)
      Get the controller partition name. The suffix PARTITION_SUFFIX is used after the regular cluster name.
      Parameters:
      veniceClusterName - Venice cluster name.
      Returns:
      partition name for the input Venice cluster.
    • getResources

      protected Optional<HelixVeniceClusterResources> getResources()
      Returns:
      an Optional describing the Venice cluster aggregated resources, if non-null, otherwise returns an empty Optional.
    • getClusterName

      protected String getClusterName()
      Returns:
      the name of the Venice cluster that the model manages.