S
- the type of stateE
- the type of eventpublic class ZookeeperStateMachineEnsemble<S,E> extends StateMachineEnsembleObjectSupport<S,E>
StateMachineEnsemble
backed by a zookeeper.Constructor and Description |
---|
ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient,
java.lang.String basePath)
Instantiates a new zookeeper state machine ensemble.
|
ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient,
java.lang.String basePath,
boolean cleanState,
int logSize)
Instantiates a new zookeeper state machine ensemble.
|
Modifier and Type | Method and Description |
---|---|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStartReactively()
Subclasses may implement this for pre start logic.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStopReactively()
Subclasses may implement this for pre stop logic.
|
protected void |
doStart() |
protected void |
doStop() |
StateMachine<S,E> |
getLeader()
Gets the ensemble leader.
|
StateMachineContext<S,E> |
getState()
Gets the state as a
StateMachineContext . |
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 |
registerWatcherForStatePath()
Register existing
CuratorWatcher for a state path. |
void |
setState(StateMachineContext<S,E> context)
Sets the state as a
StateMachineContext . |
java.lang.String |
toString() |
addEnsembleListener, notifyError, notifyGranted, notifyJoined, notifyLeft, notifyRevoked, notifyStateChanged, removeEnsembleListener
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactively
public ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, java.lang.String basePath)
curatorClient
- the curator clientbasePath
- the base zookeeper pathpublic ZookeeperStateMachineEnsemble(org.apache.curator.framework.CuratorFramework curatorClient, java.lang.String basePath, boolean cleanState, int logSize)
curatorClient
- the curator clientbasePath
- the base zookeeper pathcleanState
- if true clean existing statelogSize
- the log sizeprotected void onInit() throws java.lang.Exception
LifecycleObjectSupport
InitializingBean
phase.onInit
in class LifecycleObjectSupport
java.lang.Exception
- exceptionprotected reactor.core.publisher.Mono<java.lang.Void> doPreStartReactively()
LifecycleObjectSupport
doPreStartReactively
in class LifecycleObjectSupport
protected void doStart()
protected reactor.core.publisher.Mono<java.lang.Void> doPreStopReactively()
LifecycleObjectSupport
doPreStopReactively
in class LifecycleObjectSupport
protected void doStop()
public void join(StateMachine<S,E> stateMachine)
StateMachineEnsemble
EnsembleListener
and
EnsembleListener.stateMachineJoined(StateMachine, StateMachineContext)
is called with a StateMachine
instance for successful join.join
in interface StateMachineEnsemble<S,E>
join
in class StateMachineEnsembleObjectSupport<S,E>
stateMachine
- the state machinepublic StateMachine<S,E> getLeader()
StateMachineEnsemble
NULL
it indicates that this ensemble
doesn't know any leader.public void leave(StateMachine<S,E> stateMachine)
StateMachineEnsemble
StateMachine
. Additionally
EnsembleListener.stateMachineLeft(StateMachine, StateMachineContext)
is called when leave request is fully processed.leave
in interface StateMachineEnsemble<S,E>
leave
in class StateMachineEnsembleObjectSupport<S,E>
stateMachine
- the state machinepublic void setState(StateMachineContext<S,E> context)
StateMachineEnsemble
StateMachineContext
.context
- the state machine contextpublic StateMachineContext<S,E> getState()
StateMachineEnsemble
StateMachineContext
.protected void registerWatcherForStatePath()
CuratorWatcher
for a state path.public java.lang.String toString()
toString
in class java.lang.Object