Class ZookeeperStateMachineEnsemble<S,E>
java.lang.Object
org.springframework.statemachine.support.LifecycleObjectSupport
org.springframework.statemachine.ensemble.StateMachineEnsembleObjectSupport<S,E>
org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble<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
- Direct Known Subclasses:
LeaderZookeeperStateMachineEnsemble
StateMachineEnsemble backed by a zookeeper.- Author:
- Janne Valkealahti
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath) Instantiates a new zookeeper state machine ensemble.ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath, boolean cleanState, int logSize) Instantiates a new zookeeper state machine ensemble. -
Method Summary
Modifier and TypeMethodDescriptionprotected reactor.core.publisher.Mono<Void>Subclasses may implement this for pre start logic.protected reactor.core.publisher.Mono<Void>Subclasses may implement this for pre stop logic.protected voiddoStart()protected voiddoStop()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.protected voidonInit()Subclasses may implement this for initialization logic.protected voidRegister existingCuratorWatcherfor a state path.voidsetState(StateMachineContext<S, E> context) Sets the state as aStateMachineContext.toString()Methods 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
-
ZookeeperStateMachineEnsemble
public ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath) Instantiates a new zookeeper state machine ensemble.- Parameters:
curatorClient- the curator clientbasePath- the base zookeeper path
-
ZookeeperStateMachineEnsemble
public ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, String basePath, boolean cleanState, int logSize) Instantiates a new zookeeper state machine ensemble.- Parameters:
curatorClient- the curator clientbasePath- the base zookeeper pathcleanState- if true clean existing statelogSize- the log size
-
-
Method Details
-
onInit
Description copied from class:LifecycleObjectSupportSubclasses may implement this for initialization logic. Called during theInitializingBeanphase.- Overrides:
onInitin classLifecycleObjectSupport- Throws:
Exception- exception
-
doPreStartReactively
Description copied from class:LifecycleObjectSupportSubclasses may implement this for pre start logic.- Overrides:
doPreStartReactivelyin classLifecycleObjectSupport- Returns:
- the mono for completion
-
doStart
protected void doStart() -
doPreStopReactively
Description copied from class:LifecycleObjectSupportSubclasses may implement this for pre stop logic.- Overrides:
doPreStopReactivelyin classLifecycleObjectSupport- Returns:
- the mono for completion
-
doStop
protected void doStop() -
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> - Specified by:
joinin classStateMachineEnsembleObjectSupport<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.- Returns:
- the ensemble leader
-
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> - Specified by:
leavein classStateMachineEnsembleObjectSupport<S,E> - Parameters:
stateMachine- the state machine
-
setState
Description copied from interface:StateMachineEnsembleSets the state as aStateMachineContext.- Parameters:
context- the state machine context
-
getState
Description copied from interface:StateMachineEnsembleGets the state as aStateMachineContext.- Returns:
- the state machine context
-
registerWatcherForStatePath
protected void registerWatcherForStatePath()Register existingCuratorWatcherfor a state path. -
toString
-