Interface StateMachineEnsemble<S,E>
- Type Parameters:
S
- the type of stateE
- the type of event
- All Known Implementing Classes:
LeaderZookeeperStateMachineEnsemble
,StateMachineEnsembleObjectSupport
,ZookeeperStateMachineEnsemble
public interface StateMachineEnsemble<S,E>
StateMachineEnsemble
is a contract between a StateMachine
and
arbitrary ensemble of other StateMachine
s.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEnsembleListener
(EnsembleListener<S, E> listener) Adds the ensemble listener.Gets the ensemble leader.getState()
Gets the state as aStateMachineContext
.void
join
(StateMachine<S, E> stateMachine) Request a join to a state machine ensemble.void
leave
(StateMachine<S, E> stateMachine) Request a leave from an ensemble.void
removeEnsembleListener
(EnsembleListener<S, E> listener) Removes the ensemble listener.void
setState
(StateMachineContext<S, E> context) Sets the state as aStateMachineContext
.
-
Method Details
-
join
Request a join to a state machine ensemble. This method is a request to join an ensemble and doesn't guarantee a requester will eventually successfully join. Join operation needs to be used together withEnsembleListener
andEnsembleListener.stateMachineJoined(StateMachine, StateMachineContext)
is called with aStateMachine
instance for successful join.- Parameters:
stateMachine
- the state machine
-
leave
Request a leave from an ensemble. This method is a request to leave an ensemble. After this method is called no further processing is done for a instance ofStateMachine
. AdditionallyEnsembleListener.stateMachineLeft(StateMachine, StateMachineContext)
is called when leave request is fully processed.- Parameters:
stateMachine
- the state machine
-
addEnsembleListener
Adds the ensemble listener.- Parameters:
listener
- the listener
-
removeEnsembleListener
Removes the ensemble listener.- Parameters:
listener
- the listener
-
setState
Sets the state as aStateMachineContext
.- Parameters:
context
- the state machine context
-
getState
StateMachineContext<S,E> getState()Gets the state as aStateMachineContext
.- Returns:
- the state machine context
-
getLeader
StateMachine<S,E> getLeader()Gets the ensemble leader. If returned machine isNULL
it indicates that this ensemble doesn't know any leader.- Returns:
- the ensemble leader
-