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.-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionLeaderZookeeperStateMachineEnsemble
(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.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.Methods inherited from class org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble
doPreStartReactively, doPreStopReactively, doStart, doStop, getState, onInit, registerWatcherForStatePath, setState, 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
-
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: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> - Overrides:
join
in classZookeeperStateMachineEnsemble<S,
E> - Parameters:
stateMachine
- the state machine
-
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> - Overrides:
leave
in classZookeeperStateMachineEnsemble<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.- Specified by:
getLeader
in interfaceStateMachineEnsemble<S,
E> - Overrides:
getLeader
in classZookeeperStateMachineEnsemble<S,
E> - Returns:
- the ensemble leader
-