Package com.linkedin.venice.controller
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.
-
Field Summary
Fields inherited from class org.apache.helix.participant.statemachine.StateModel
_cancelled, _currentState -
Constructor Summary
ConstructorsConstructorDescriptionVeniceControllerStateModel(String clusterName, org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapterSerializer, VeniceControllerMultiClusterConfig multiClusterConfigs, VeniceHelixAdmin admin, io.tehuti.metrics.MetricsRepository metricsRepository, ClusterLeaderInitializationRoutine controllerInitialization, RealTimeTopicSwitcher realTimeTopicSwitcher, Optional<DynamicAccessController> accessController, HelixAdminClient helixAdminClient, Optional<VeniceVersionLifecycleEventListener> versionLifecycleEventListener) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Shutdown the internal executor service.protected Stringprotected static StringgetPartitionNameFromVeniceClusterName(String veniceClusterName) Get the controller partition name.protected Optional<HelixVeniceClusterResources>protected static StringgetVeniceClusterNameFromPartitionName(String partitionName) Get the regular Venice cluster name after removing the suffixPARTITION_SUFFIX.booleanisLeader()Test if current state isHelixState.LEADER_STATE.voidonBecomeDroppedFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.ERROR_STATEtoHelixState.DROPPED_STATE.voidonBecomeDroppedFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATEtoHelixState.DROPPED_STATE.voidonBecomeLeaderFromStandby(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.STANDBY_STATEtoHelixState.LEADER_STATE.voidonBecomeOfflineFromStandby(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.STANDBY_STATEtoHelixState.OFFLINE_STATE.voidonBecomeStandbyFromLeader(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.LEADER_STATEtoHelixState.STANDBY_STATE.voidonBecomeStandbyFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATEtoHelixState.STANDBY_STATE.voidonBecomingOfflineFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.ERROR_STATEtoHelixState.OFFLINE_STATE.voidreset()Called when the state model is reset.voidrollbackOnError(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.booleanupdateState(String newState) This runs after the state transition occurred.Methods inherited from class org.apache.helix.participant.statemachine.StateModel
cancel, defaultTransitionHandler, getCurrentState, isCancelled, onBecomeErrorFromAny, syncState
-
Constructor Details
-
VeniceControllerStateModel
public VeniceControllerStateModel(String clusterName, org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapterSerializer, VeniceControllerMultiClusterConfig multiClusterConfigs, VeniceHelixAdmin admin, io.tehuti.metrics.MetricsRepository metricsRepository, ClusterLeaderInitializationRoutine controllerInitialization, RealTimeTopicSwitcher realTimeTopicSwitcher, Optional<DynamicAccessController> accessController, HelixAdminClient helixAdminClient, Optional<VeniceVersionLifecycleEventListener> versionLifecycleEventListener)
-
-
Method Details
-
isLeader
public boolean isLeader()Test if current state isHelixState.LEADER_STATE.- Returns:
trueif current state isHelixState.LEADER_STATE;falseotherwise.
-
updateState
This runs after the state transition occurred.- Overrides:
updateStatein classorg.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 fromHelixState.STANDBY_STATEtoHelixState.LEADER_STATE. -
onBecomeStandbyFromLeader
public void onBecomeStandbyFromLeader(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.LEADER_STATEtoHelixState.STANDBY_STATE. -
onBecomeOfflineFromStandby
public void onBecomeOfflineFromStandby(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.STANDBY_STATEtoHelixState.OFFLINE_STATE. -
onBecomeStandbyFromOffline
public void onBecomeStandbyFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATEtoHelixState.STANDBY_STATE. -
onBecomeDroppedFromOffline
public void onBecomeDroppedFromOffline(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATEtoHelixState.DROPPED_STATE. -
onBecomeDroppedFromError
public void onBecomeDroppedFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.ERROR_STATEtoHelixState.DROPPED_STATE.- Overrides:
onBecomeDroppedFromErrorin classorg.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 fromHelixState.ERROR_STATEtoHelixState.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:
rollbackOnErrorin classorg.apache.helix.participant.statemachine.StateModel
-
reset
public void reset()Called when the state model is reset.- Overrides:
resetin classorg.apache.helix.participant.statemachine.StateModel
-
getVeniceClusterNameFromPartitionName
Get the regular Venice cluster name after removing the suffixPARTITION_SUFFIX.- Parameters:
partitionName- controller partition name.- Returns:
- Venice cluster name.
-
getPartitionNameFromVeniceClusterName
Get the controller partition name. The suffixPARTITION_SUFFIXis used after the regular cluster name.- Parameters:
veniceClusterName- Venice cluster name.- Returns:
- partition name for the input Venice cluster.
-
getResources
- Returns:
- an
Optionaldescribing the Venice cluster aggregated resources, if non-null, otherwise returns an emptyOptional.
-
getClusterName
- Returns:
- the name of the Venice cluster that the model manages.
-
close
public void close()Shutdown the internal executor service.
-