Class ZookeeperStateMachinePersist<S,E>
java.lang.Object
org.springframework.statemachine.zookeeper.ZookeeperStateMachinePersist<S,E>
- Type Parameters:
S- the type of stateE- the type of event
- All Implemented Interfaces:
StateMachinePersist<S,E, org.apache.zookeeper.data.Stat>
public class ZookeeperStateMachinePersist<S,E>
extends Object
implements StateMachinePersist<S,E,org.apache.zookeeper.data.Stat>
StateMachinePersist using zookeeper as a storage and
kroy libraries as a backing serialization technique.
Persisted bytes are deserialised through Kryo with the
safe-by-default class
allowlist applied. Applications that use custom state or event types
(typically enums) must register those types via the
ZookeeperStateMachinePersist(CuratorFramework, String, String, int, Consumer)
constructor's kryoCustomizer parameter; otherwise Kryo will reject
them with IllegalArgumentException ("Class is not registered").
-
Constructor Summary
ConstructorsConstructorDescriptionZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path) Instantiates a new zookeeper state machine persist.ZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path, String logPath, int logSize) Instantiates a new zookeeper state machine persist.ZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path, String logPath, int logSize, Consumer<com.esotericsoftware.kryo.Kryo> kryoCustomizer) Instantiates a new zookeeper state machine persist with a custom Kryo configurer for application-specific allowlist registrations. -
Method Summary
Modifier and TypeMethodDescriptionread(org.apache.zookeeper.data.Stat stat) Read aStateMachineContextfrom a persistent store with a context objectT.readLog(int version, org.apache.zookeeper.data.Stat stat) voidwrite(StateMachineContext<S, E> context, org.apache.zookeeper.data.Stat stat) Write aStateMachineContextinto a persistent store with a context objectT.
-
Constructor Details
-
ZookeeperStateMachinePersist
public ZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path) Instantiates a new zookeeper state machine persist.- Parameters:
curatorClient- the curator clientpath- the path for persistent state
-
ZookeeperStateMachinePersist
public ZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path, String logPath, int logSize) Instantiates a new zookeeper state machine persist.- Parameters:
curatorClient- the curator clientpath- the pathlogPath- the log pathlogSize- the log size
-
ZookeeperStateMachinePersist
public ZookeeperStateMachinePersist(org.apache.curator.framework.CuratorFramework curatorClient, String path, String logPath, int logSize, Consumer<com.esotericsoftware.kryo.Kryo> kryoCustomizer) Instantiates a new zookeeper state machine persist with a custom Kryo configurer for application-specific allowlist registrations.- Parameters:
curatorClient- the curator clientpath- the pathlogPath- the log path (may benull)logSize- the log size (must be a positive power of two whenlogPathis set)kryoCustomizer- optional callback invoked once per Kryo instance after the framework's default registrations are applied. Use this to register application-specific state and event types (typically enums) so that they are accepted by the allowlist. May benull.- Since:
- 4.0.2
-
-
Method Details
-
write
Description copied from interface:StateMachinePersistWrite aStateMachineContextinto a persistent store with a context objectT.- Specified by:
writein interfaceStateMachinePersist<S,E, org.apache.zookeeper.data.Stat> - Parameters:
context- the contextstat- the context ojb
-
read
Description copied from interface:StateMachinePersistRead aStateMachineContextfrom a persistent store with a context objectT.- Specified by:
readin interfaceStateMachinePersist<S,E, org.apache.zookeeper.data.Stat> - Parameters:
stat- the context ojb- Returns:
- the state machine context
- Throws:
Exception- the exception
-
readLog
public StateMachineContext<S,E> readLog(int version, org.apache.zookeeper.data.Stat stat) throws Exception - Throws:
Exception
-