public interface TableMigrationStateMachine
During initialization, this state machine:
coordinatorStateDAO.initializeDelegates() so reads workTableMigrationStatus and sets the TableMigrationStatusProvidercoordinatorStateDAO.initialize() to enable writesFor 2→3 migration (where legacy tables never existed), this state machine short-circuits to COMPLETE immediately.
State transitions for 3.x→3.5 upgrade: INIT → DEPLOYED → PENDING → COMPLETE
| Modifier and Type | Method and Description |
|---|---|
void |
handleLeaderLockResult(boolean isLeader)
Called after leader election to handle table migration state transitions that
require leader ownership.
|
void |
initialize()
Initialize the table migration state machine.
|
void |
shutdown()
Idempotent shutdown of the table migration state machine.
|
void initialize()
throws DependencyException,
InvalidStateException
This method:
coordinatorStateDAO.initializeDelegates() — legacy checks table existenceTableMigrationStatusProvider with the determined statuscoordinatorStateDAO.initialize() to enable write operationsIf it fails, the Scheduler retries the entire initialization. On retry, if already initialized, this is a no-op.
DependencyException - if DDB operations failInvalidStateException - if the state is inconsistentvoid handleLeaderLockResult(boolean isLeader)
throws DependencyException,
InvalidStateException
When the PENDING → COMPLETE transition completes (async copy done, status updated),
this method throws InvalidStateException to signal the caller to release the
current leader lock (held on the legacy table). The next isLeader check will
use the updated TableMigrationStatusProvider (now COMPLETE) to acquire the lock
from the lease table instead.
isLeader - whether the current worker holds the leader lockDependencyException - if DDB read/write fails — caller should treat as transient
and retry on the next cycle (e.g., isLeader returns false for this cycle)InvalidStateException - when the migration has just completed and the caller
must release the current lock so the correct lock can be acquiredvoid shutdown()
After this method returns, no further DDB mutations will be performed by the state machine. This should be called during scheduler shutdown to ensure a leader shutting down mid-copy does not continue mutating DDB tables after the worker considers itself stopped.
Calling this method multiple times is safe and has no additional effect.
Copyright © 2026. All rights reserved.