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
ConstructorDescriptionVeniceControllerStateModel
(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) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected static String
getPartitionNameFromVeniceClusterName
(String veniceClusterName) Get the controller partition name.protected Optional<HelixVeniceClusterResources>
protected static String
getVeniceClusterNameFromPartitionName
(String partitionName) Get the regular Venice cluster name after removing the suffixPARTITION_SUFFIX
.boolean
isLeader()
Test if current state isHelixState.LEADER_STATE
.void
onBecomeDroppedFromError
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.ERROR_STATE
toHelixState.DROPPED_STATE
.void
onBecomeDroppedFromOffline
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATE
toHelixState.DROPPED_STATE
.void
onBecomeLeaderFromStandby
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.STANDBY_STATE
toHelixState.LEADER_STATE
.void
onBecomeOfflineFromStandby
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.STANDBY_STATE
toHelixState.OFFLINE_STATE
.void
onBecomeStandbyFromLeader
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.LEADER_STATE
toHelixState.STANDBY_STATE
.void
onBecomeStandbyFromOffline
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.OFFLINE_STATE
toHelixState.STANDBY_STATE
.void
onBecomingOfflineFromError
(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context) A callback for Helix state transition fromHelixState.ERROR_STATE
toHelixState.OFFLINE_STATE
.void
reset()
Called when the state model is reset.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.boolean
updateState
(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)
-
-
Method Details
-
isLeader
public boolean isLeader()Test if current state isHelixState.LEADER_STATE
.- Returns:
true
if current state isHelixState.LEADER_STATE
;false
otherwise.
-
updateState
This runs after the state transition occurred.- Overrides:
updateState
in 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_STATE
toHelixState.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_STATE
toHelixState.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_STATE
toHelixState.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_STATE
toHelixState.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_STATE
toHelixState.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_STATE
toHelixState.DROPPED_STATE
.- Overrides:
onBecomeDroppedFromError
in 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_STATE
toHelixState.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 classorg.apache.helix.participant.statemachine.StateModel
-
reset
public void reset()Called when the state model is reset.- Overrides:
reset
in 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_SUFFIX
is used after the regular cluster name.- Parameters:
veniceClusterName
- Venice cluster name.- Returns:
- partition name for the input Venice cluster.
-
getResources
- Returns:
- an
Optional
describing the Venice cluster aggregated resources, if non-null, otherwise returns an emptyOptional
.
-
getClusterName
- Returns:
- the name of the Venice cluster that the model manages.
-