public abstract class StateMachine extends Object implements AutoCloseable
Users should extend this class to create a state machine for use within a RaftServer.
State machines are responsible for handling operations submitted to the Raft
cluster and filtering committed operations out of the Raft log. The most
important rule of state machines is that state machines must be deterministic in order to maintain Catalog's
consistency guarantees. That is, state machines must not change their behavior based on external influences and have
no side effects. Users should never use System time to control behavior within a state machine.
When commands and queries are submitted
to the Raft cluster, the RaftServer will log and replicate them as necessary
and, once complete, apply them to the configured state machine.
Commit| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the state machine.
|
void |
close(Session session)
Called when a session is closed.
|
abstract void |
configure(StateMachineExecutor executor)
Configures the state machine.
|
void |
expire(Session session)
Called when a session is expired.
|
void |
init(StateMachineContext context)
Initializes the state machine.
|
void |
register(Session session)
Called when a new session is registered.
|
public void init(StateMachineContext context)
context - The state machine context.NullPointerException - if context is nullpublic abstract void configure(StateMachineExecutor executor)
executor - The state machine executor.public void register(Session session)
session - The session that was registered.public void expire(Session session)
session - The expired session.public void close(Session session)
session - The session that was closed.public void close()
close in interface AutoCloseableCopyright © 2013–2015. All rights reserved.