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
ConstructorDescriptionZookeeperStateMachineEnsemble
(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 void
doStart()
protected void
doStop()
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.protected void
onInit()
Subclasses may implement this for initialization logic.protected void
Register existingCuratorWatcher
for a state path.void
setState
(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, removeEnsembleListener
Methods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactively
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:LifecycleObjectSupport
Subclasses may implement this for initialization logic. Called during theInitializingBean
phase.- Overrides:
onInit
in classLifecycleObjectSupport
- Throws:
Exception
- exception
-
doPreStartReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre start logic.- Overrides:
doPreStartReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
doStart
protected void doStart() -
doPreStopReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre stop logic.- Overrides:
doPreStopReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
doStop
protected void doStop() -
join
Description copied from interface:StateMachineEnsemble
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.- Specified by:
join
in interfaceStateMachineEnsemble<S,
E> - Specified by:
join
in classStateMachineEnsembleObjectSupport<S,
E> - Parameters:
stateMachine
- the state machine
-
getLeader
Description copied from interface:StateMachineEnsemble
Gets the ensemble leader. If returned machine isNULL
it indicates that this ensemble doesn't know any leader.- Returns:
- the ensemble leader
-
leave
Description copied from interface:StateMachineEnsemble
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.- Specified by:
leave
in interfaceStateMachineEnsemble<S,
E> - Specified by:
leave
in classStateMachineEnsembleObjectSupport<S,
E> - Parameters:
stateMachine
- the state machine
-
setState
Description copied from interface:StateMachineEnsemble
Sets the state as aStateMachineContext
.- Parameters:
context
- the state machine context
-
getState
Description copied from interface:StateMachineEnsemble
Gets the state as aStateMachineContext
.- Returns:
- the state machine context
-
registerWatcherForStatePath
protected void registerWatcherForStatePath()Register existingCuratorWatcher
for a state path. -
toString
-