@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class StateMachineProcedure<TEnvironment,TState> extends Procedure<TEnvironment>
Modifier and Type | Class and Description |
---|---|
protected static class |
StateMachineProcedure.Flow |
Constructor and Description |
---|
StateMachineProcedure() |
Modifier and Type | Method and Description |
---|---|
protected void |
deserializeStateData(InputStream stream)
Called on store load to allow the user to decode the previously serialized
state.
|
protected Procedure[] |
execute(TEnvironment env)
The main code of the procedure.
|
protected abstract StateMachineProcedure.Flow |
executeFromState(TEnvironment env,
TState state)
called to perform a single step of the specified 'state' of the procedure
|
protected abstract TState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
protected abstract TState |
getState(int stateId)
Convert an ordinal (or state id) to an Enum (or more descriptive) state object.
|
protected abstract int |
getStateId(TState state)
Convert the Enum (or more descriptive) state object to an ordinal (or state id).
|
protected void |
rollback(TEnvironment env)
The code to undo what done by the execute() code.
|
protected abstract void |
rollbackState(TEnvironment env,
TState state)
called to perform the rollback of the specified state
|
protected void |
serializeStateData(OutputStream stream)
The user-level code of the procedure may have some state to
persist (e.g.
|
protected void |
setNextState(TState state)
Set the next state for the procedure.
|
abort, acquireLock, addStackIndex, beforeReplay, childrenCountDown, compareTo, completionCleanup, convert, convert, createProcedureInfo, doExecute, doRollback, elapsedTime, getException, getLastUpdate, getOwner, getParentProcId, getProcId, getResult, getRootProcedureId, getStackIndexes, getStartTime, getState, getTimeout, getTimeRemaining, hasException, hasOwner, hasParent, hasTimeout, incChildrenLatch, isFailed, isFinished, isSuccess, isWaiting, newInstance, releaseLock, removeStackIndex, setAbortFailure, setChildrenLatch, setFailure, setFailure, setOwner, setParentProcId, setProcId, setResult, setStackIndexes, setStartTime, setState, setTimeout, setTimeoutFailure, toString, toStringClass, toStringClassDetails, updateTimestamp, validateClass, wasExecuted
protected abstract StateMachineProcedure.Flow executeFromState(TEnvironment env, TState state) throws ProcedureYieldException
state
- state to executeProcedureYieldException
protected abstract void rollbackState(TEnvironment env, TState state) throws IOException
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterprotected abstract TState getState(int stateId)
stateId
- the ordinal() of the state enum (or state id)protected abstract int getStateId(TState state)
state
- the state enum objectprotected abstract TState getInitialState()
protected void setNextState(TState state)
state
- the state enum objectprotected Procedure[] execute(TEnvironment env) throws ProcedureYieldException
Procedure
execute
in class Procedure<TEnvironment>
ProcedureYieldException
protected void rollback(TEnvironment env) throws IOException
Procedure
rollback
in class Procedure<TEnvironment>
IOException
- temporary failure, the rollback will retry laterprotected void serializeStateData(OutputStream stream) throws IOException
Procedure
serializeStateData
in class Procedure<TEnvironment>
stream
- the stream that will contain the user serialized dataIOException
protected void deserializeStateData(InputStream stream) throws IOException
Procedure
deserializeStateData
in class Procedure<TEnvironment>
stream
- the stream that contains the user serialized dataIOException