Interface ReplicatedStateMachine
public interface ReplicatedStateMachine
Deterministic application state owned by one consensus node. Callbacks are serialized;
callbacks must not invoke their node, use wall clocks, or perform network operations.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidappliedThrough(long index) Advances the applied watermark for every committed entry, including internal metadata.voidapply(long index, byte[] command) Applies one committed command exactly once within a recovery generation.default voidapply(long index, long term, byte[] command) Applies a committed command with its authoritative consensus leadership term.voidrestore(byte[] snapshot) Replaces state before replaying the suffix; implementations must validate before mutation.byte[]snapshot()Captures all application state after the last apply.
-
Method Details
-
apply
void apply(long index, byte[] command) Applies one committed command exactly once within a recovery generation.- Parameters:
index- globally ordered log positioncommand- immutable command copy
-
apply
default void apply(long index, long term, byte[] command) Applies a committed command with its authoritative consensus leadership term. The default preserves existing implementations; epoch-aware resources override this callback.- Parameters:
index- globally ordered committed log positionterm- positive term persisted in this log entry, never a caller-supplied epochcommand- immutable command copy
-
appliedThrough
default void appliedThrough(long index) Advances the applied watermark for every committed entry, including internal metadata.- Parameters:
index- fully applied log position
-
snapshot
byte[] snapshot()Captures all application state after the last apply.- Returns:
- independent snapshot bytes, never null
-
restore
void restore(byte[] snapshot) Replaces state before replaying the suffix; implementations must validate before mutation.- Parameters:
snapshot- previously captured application state
-