@ThreadSafe public abstract class StateMachine<S extends BalancerOperationState,E extends BalancerOperationEvent> extends Object
Modifier and Type | Field and Description |
---|---|
protected S |
currentState |
Modifier | Constructor and Description |
---|---|
|
StateMachine(int brokerId,
String name,
S startState,
long createTimeMs,
long lastUpdateTimeMs,
org.apache.kafka.common.utils.Time time)
Used when restoring a state machine from persisted state.
|
|
StateMachine(int brokerId,
String name,
S startState,
org.apache.kafka.common.utils.Time time) |
protected |
StateMachine(Set<Integer> brokerIds,
String name,
S startState,
org.apache.kafka.common.utils.Time time) |
Modifier and Type | Method and Description |
---|---|
S |
advanceState(E event)
React to an event #
E by advancing the state machine. |
long |
createTime() |
boolean |
isTerminalState(S state) |
long |
lastUpdateTime() |
protected volatile S extends BalancerOperationState currentState
public StateMachine(int brokerId, String name, S startState, org.apache.kafka.common.utils.Time time)
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
- Initial state of the state machine.time
- Time object to use to get current time.public StateMachine(int brokerId, String name, S startState, long createTimeMs, long lastUpdateTimeMs, org.apache.kafka.common.utils.Time time)
brokerId
- - the broker ID that this state machine will operate onname
- - the name of the operation that this state machine represents (e.g "EvenClusterLoad")startState
- - the state of the persisted state machine.createTimeMs
- - the time the state machine was created the very first time.lastUpdateTimeMs
- - the time the state machine was last updated.time
- - Time object to use to get the current time.protected StateMachine(Set<Integer> brokerIds, String name, S startState, org.apache.kafka.common.utils.Time time)
brokerIds
- - the broker IDs that this state machine will operate onname
- - the name of the operation that this state machine represents (e.g "Broker Removal")startState
- Initial state of the state machine.time
- Time object to use to get current time.public boolean isTerminalState(S state)
public long createTime()
public long lastUpdateTime()
public S advanceState(E event)
E
by advancing the state machine.event
- - the newly-occurred event on the operation this state machine is trackingIllegalStateException
- if the state transition is invalid