Class LeaderZookeeperStateMachineEnsemble<S,E>
java.lang.Object
org.springframework.statemachine.support.LifecycleObjectSupport
org.springframework.statemachine.ensemble.StateMachineEnsembleObjectSupport<S,E>
org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble<S,E>
org.springframework.statemachine.cluster.LeaderZookeeperStateMachineEnsemble<S,E>
- Type Parameters:
S- the type of stateE- the type of event
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,StateMachineEnsemble<S,,E> StateMachineReactiveLifecycle
StateMachineEnsemble backed by a zookeeper and leader functionality
from a Spring Cloud Cluster.- Author:
- Janne Valkealahti
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionLeaderZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath) Instantiates a new leader zookeeper state machine ensemble.LeaderZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath, boolean cleanState, int logSize) Instantiates a new leader zookeeper state machine ensemble. -
Method Summary
Modifier and TypeMethodDescriptionGets the ensemble leader.voidjoin(StateMachine<S, E> stateMachine) Request a join to a state machine ensemble.voidleave(StateMachine<S, E> stateMachine) Request a leave from an ensemble.Methods inherited from class org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble
doPreStartReactively, doPreStopReactively, doStart, doStop, getState, onInit, registerWatcherForStatePath, setState, toStringMethods inherited from class org.springframework.statemachine.ensemble.StateMachineEnsembleObjectSupport
addEnsembleListener, notifyError, notifyGranted, notifyJoined, notifyLeft, notifyRevoked, notifyStateChanged, removeEnsembleListenerMethods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactivelyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
LeaderZookeeperStateMachineEnsemble
public LeaderZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath) Instantiates a new leader zookeeper state machine ensemble.- Parameters:
curatorClient- the curator clientbasePath- the base zookeeper path
-
LeaderZookeeperStateMachineEnsemble
public LeaderZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath, boolean cleanState, int logSize) Instantiates a new leader zookeeper state machine ensemble.- Parameters:
curatorClient- the curator clientbasePath- the base zookeeper pathcleanState- if true clean existing statelogSize- the log size
-
-
Method Details
-
join
Description copied from interface:StateMachineEnsembleRequest 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.- Specified by:
joinin interfaceStateMachineEnsemble<S,E> - Overrides:
joinin classZookeeperStateMachineEnsemble<S,E> - Parameters:
stateMachine- the state machine
-
leave
Description copied from interface:StateMachineEnsembleRequest 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.- Specified by:
leavein interfaceStateMachineEnsemble<S,E> - Overrides:
leavein classZookeeperStateMachineEnsemble<S,E> - Parameters:
stateMachine- the state machine
-
getLeader
Description copied from interface:StateMachineEnsembleGets the ensemble leader. If returned machine isNULLit indicates that this ensemble doesn't know any leader.- Specified by:
getLeaderin interfaceStateMachineEnsemble<S,E> - Overrides:
getLeaderin classZookeeperStateMachineEnsemble<S,E> - Returns:
- the ensemble leader
-