Facilitates registration and execution of state machine commands and provides deterministic scheduling.
The state machine executor is responsible for managing input to and output from a
As operations are committed to the Raft log, the executor is responsible for applying them to the state machine.
OperationType#COMMAND are guaranteed to be applied to the state machine in the order in which
they appear in the Raft log and always in the same thread, so state machines don't have to be thread safe.
OperationType#QUERY are not generally written to the Raft log and will instead be applied according
State machines can use the executor to provide deterministic scheduling during the execution of command callbacks.
private Object putWithTtl(Commit commit) );
As with all state machine callbacks, the executor will ensure scheduled callbacks are executed sequentially and
deterministically. As long as state machines schedule callbacks deterministically, callbacks will be executed
deterministically. Internally, the state machine executor triggers callbacks based on various timestamps in the
Raft log. This means the scheduler is dependent on internal or user-defined operations being written to the log.
Prior to the execution of a command, any expired scheduled callbacks will be executed based on the command's
It's important to note that callbacks can only be scheduled during
PrimitiveOperation operations or by recursive
scheduling. If a state machine attempts to schedule a callback via the executor during the execution of a
IllegalStateException will be thrown. This is because queries are usually only applied
on a single state machine within the cluster, and so scheduling callbacks in reaction to query execution would
not be deterministic.