@ThreadSafe
public abstract class StateMachine<S extends BalancerOperationState,E extends BalancerOperationEvent>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected S |
currentState |
Constructor and Description |
---|
StateMachine(int brokerId,
java.lang.String name,
S startState) |
Modifier and Type | Method and Description |
---|---|
S |
advanceState(E event)
React to an event #
E by advancing the state machine. |
boolean |
isTerminalState(S state) |
protected volatile S extends BalancerOperationState currentState
public StateMachine(int brokerId, java.lang.String name, S startState)
brokerId
- - the broker ID that this state machine will operate onname
- - the name of the operation that this state machine represents (e.g "Broker Removal")startState
- public boolean isTerminalState(S state)
public S advanceState(E event)
E
by advancing the state machine.event
- - the newly-occurred event on the operation this state machine is trackingjava.lang.IllegalStateException
- if the state transition is invalid