@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, getNonceKey, 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, setNonceKey, setOwner, setParentProcId, setProcId, setResult, setStackIndexes, setStartTime, setState, setTimeout, setTimeoutFailure, toString, toStringClass, toStringClassDetails, toStringDetails, toStringSimpleSB, updateTimestamp, validateClass, wasExecutedprotected abstract StateMachineProcedure.Flow executeFromState(TEnvironment env, TState state) throws ProcedureYieldException
state - state to executeProcedureYieldExceptionprotected 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
Procedureexecute in class Procedure<TEnvironment>env - the environment passed to the ProcedureExecutorProcedureYieldException - the procedure will be added back to the queue and retried laterprotected void rollback(TEnvironment env) throws IOException
Procedurerollback in class Procedure<TEnvironment>env - the environment passed to the ProcedureExecutorIOException - temporary failure, the rollback will retry laterprotected void serializeStateData(OutputStream stream) throws IOException
ProcedureserializeStateData in class Procedure<TEnvironment>stream - the stream that will contain the user serialized dataIOException - failure to stream dataprotected void deserializeStateData(InputStream stream) throws IOException
ProceduredeserializeStateData in class Procedure<TEnvironment>stream - the stream that contains the user serialized dataIOException