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 StateMachines.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnsembleListener(EnsembleListener<S, E> listener) Adds the ensemble listener.Gets the ensemble leader.getState()Gets the state as aStateMachineContext.voidjoin(StateMachine<S, E> stateMachine) Request a join to a state machine ensemble.voidleave(StateMachine<S, E> stateMachine) Request a leave from an ensemble.voidremoveEnsembleListener(EnsembleListener<S, E> listener) Removes the ensemble listener.voidsetState(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 withEnsembleListenerandEnsembleListener.stateMachineJoined(StateMachine, StateMachineContext)is called with aStateMachineinstance 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 isNULLit indicates that this ensemble doesn't know any leader.- Returns:
- the ensemble leader
-