Class AbstractPartitionStateModel

java.lang.Object
org.apache.helix.participant.statemachine.StateModel
com.linkedin.davinci.helix.AbstractPartitionStateModel
Direct Known Subclasses:
LeaderFollowerPartitionStateModel

public abstract class AbstractPartitionStateModel extends org.apache.helix.participant.statemachine.StateModel
An abstraction of Helix State model behavior registry that defines how participants (Storage node) fetch data from Kafka. Helix state model is state machine defined by "states" and transitions (edges from one state to the other). In order to make Helix state machine work, 2 parts are required. 1. A model definition that defines all available states and transitions. 2. A behavior registry that defines what participant should do during transitions before moving to next state. Currently, we support LeaderStandbyModel participant model. Check out LeaderStandbySMD for model definition and LeaderFollowerPartitionStateModel for behavior registry.
  • Field Details

    • logger

      protected final org.apache.logging.log4j.Logger logger
    • WAIT_DROP_PARTITION_TIME_OUT_MS

      protected static final long WAIT_DROP_PARTITION_TIME_OUT_MS
  • Constructor Details

  • Method Details

    • executeStateTransition

      protected void executeStateTransition(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context, Runnable handler)
    • executeStateTransition

      protected void executeStateTransition(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context, Runnable handler, boolean rollback)
    • rollbackOnError

      public void rollbackOnError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context, org.apache.helix.participant.statemachine.StateTransitionError error)
      Stop the consumption once a replica become ERROR. This function only does clean up when any state transition fails, and it won't retry any state transition.
      Overrides:
      rollbackOnError in class org.apache.helix.participant.statemachine.StateModel
    • onBecomeDroppedFromError

      public void onBecomeDroppedFromError(org.apache.helix.model.Message message, org.apache.helix.NotificationContext context)
      Handles ERROR->DROPPED transition. Unexpected Transition. Unsubscribe the partition, removes partition's data from local storage and clears the committed offset.
      Overrides:
      onBecomeDroppedFromError in class org.apache.helix.participant.statemachine.StateModel
    • reset

      public void reset()
      Overrides:
      reset in class org.apache.helix.participant.statemachine.StateModel
    • waitForVersionToBeAvailable

      protected void waitForVersionToBeAvailable()
      Waits for the version metadata to become available in the store repository using exponential backoff. During OFFLINE->STANDBY transitions, version info may not have propagated from ZK yet. This must be called before the storage engine is created so that the correct partition type (with or without replication metadata) is used.
    • setupNewStorePartition

      protected void setupNewStorePartition()
      set up a new store partition and start the ingestion
    • removePartitionFromStoreGracefully

      protected CompletableFuture<Void> removePartitionFromStoreGracefully()
    • removeCustomizedState

      protected void removeCustomizedState()
      remove customized state for this partition if there is one
    • waitConsumptionCompleted

      protected void waitConsumptionCompleted(String resourceName, StateModelIngestionProgressNotifier notifier)
    • waitUntilFutureVersionLagAcceptable

      protected void waitUntilFutureVersionLagAcceptable(String resourceName)
      Best-effort wait, applicable to a future-version replica whose push is still in progress (i.e. the version's status is VersionStatus.STARTED), for the replica's local version topic lag to drop to or below an acceptable threshold before completing the OFFLINE -> STANDBY transition. Callers are expected to only invoke this method when VeniceServerConfig.isFutureVersionStandbyLagCheckEnabled() is true. Unlike waitConsumptionCompleted(java.lang.String, com.linkedin.davinci.helix.StateModelIngestionProgressNotifier), this does not wait for ingestion to fully complete: it only waits until the measured lag is within VeniceServerConfig.getFutureVersionStandbyLagThreshold(), or until VeniceServerConfig.getFutureVersionStandbyLagCheckTimeoutMinutes() elapses, whichever happens first. If lag cannot be measured, or the ingestion task is not found, this method returns immediately, preserving the pre-existing (no-wait) behavior for this case. The version's status is re-checked on every poll so that a version which transitions away from VersionStatus.STARTED while waiting (e.g. to VersionStatus.KILLED or VersionStatus.ERROR due to an asynchronous kill/cleanup racing with this transition) does not needlessly occupy the state-transition worker thread until the full timeout elapses.
    • stopConsumption

      protected void stopConsumption(boolean dropCVState)
    • getIngestionBackend

      protected IngestionBackend getIngestionBackend()
    • getStoreIngestionService

      protected StoreIngestionService getStoreIngestionService()
    • getStoreRepo

      protected ReadOnlyStoreRepository getStoreRepo()
    • getStoreAndServerConfigs

      protected VeniceStoreVersionConfig getStoreAndServerConfigs()
    • getPartition

      protected int getPartition()
    • getStoreName

      protected String getStoreName()
    • getVersionNumber

      protected int getVersionNumber()
    • getStorePartitionDescription

      public String getStorePartitionDescription()
    • getStoreVersionRole

      protected String getStoreVersionRole()
      Returns the role of this store version (CURRENT, BACKUP, or FUTURE) as a string. This is a best-effort operation - during rollbacks or metadata inconsistencies, the reported role may be temporarily inaccurate (e.g., a backup version may briefly appear as FUTURE).
      Returns:
      the store version role name, or empty string if store metadata is unavailable
    • getStoreVersionType

      protected VeniceStoreType getStoreVersionType()