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 void |
doStart()
Subclasses may implement this method with the start behavior.
|
protected void |
doStop()
Subclasses may implement this method with the stop behavior.
|
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, removeEnsembleListenerafterPropertiesSet, destroy, doDestroy, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stoppublic 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
LifecycleObjectSupportInitializingBean phase. Implementor should
always call super method not to break initialization chain.onInit in class LifecycleObjectSupportjava.lang.Exception - exceptionprotected void doStart()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStart in class LifecycleObjectSupportprotected void doStop()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStop in class LifecycleObjectSupportpublic void join(StateMachine<S,E> stateMachine)
StateMachineEnsembleEnsembleListener 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()
StateMachineEnsembleNULL it indicates that this ensemble
doesn't know any leader.public void leave(StateMachine<S,E> stateMachine)
StateMachineEnsembleStateMachine. 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)
StateMachineEnsembleStateMachineContext.context - the state machine contextpublic StateMachineContext<S,E> getState()
StateMachineEnsembleStateMachineContext.protected void registerWatcherForStatePath()
CuratorWatcher for a state path.public java.lang.String toString()
toString in class java.lang.Object