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, removeEnsembleListener
afterPropertiesSet, destroy, doDestroy, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stop
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. Implementor should
always call super method not to break initialization chain.onInit
in class LifecycleObjectSupport
java.lang.Exception
- exceptionprotected void doStart()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStart
in class LifecycleObjectSupport
protected void doStop()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStop
in class LifecycleObjectSupport
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