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.
-
-
Constructor Summary
Constructors Constructor Description VeniceControllerStateModel(java.lang.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, java.util.Optional<DynamicAccessController> accessController, HelixAdminClient helixAdminClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getClusterName()
protected static java.lang.String
getPartitionNameFromVeniceClusterName(java.lang.String veniceClusterName)
Get the controller partition name.protected java.util.Optional<HelixVeniceClusterResources>
getResources()
protected static java.lang.String
getVeniceClusterNameFromPartitionName(java.lang.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(java.lang.String newState)
This runs after the state transition occurred.
-
-
-
Constructor Detail
-
VeniceControllerStateModel
public VeniceControllerStateModel(java.lang.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, java.util.Optional<DynamicAccessController> accessController, HelixAdminClient helixAdminClient)
-
-
Method Detail
-
isLeader
public boolean isLeader()
Test if current state isHelixState.LEADER_STATE
.- Returns:
true
if current state isHelixState.LEADER_STATE
;false
otherwise.
-
updateState
public boolean updateState(java.lang.String newState)
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
protected static java.lang.String getVeniceClusterNameFromPartitionName(java.lang.String partitionName)
Get the regular Venice cluster name after removing the suffixPARTITION_SUFFIX
.- Parameters:
partitionName
- controller partition name.- Returns:
- Venice cluster name.
-
getPartitionNameFromVeniceClusterName
protected static java.lang.String getPartitionNameFromVeniceClusterName(java.lang.String veniceClusterName)
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
protected java.util.Optional<HelixVeniceClusterResources> getResources()
- Returns:
- an
Optional
describing the Venice cluster aggregated resources, if non-null, otherwise returns an emptyOptional
.
-
getClusterName
protected java.lang.String getClusterName()
- Returns:
- the name of the Venice cluster that the model manages.
-
-