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 Type
    Method
    Description
    default void
    appliedThrough(long index)
    Advances the applied watermark for every committed entry, including internal metadata.
    void
    apply(long index, byte[] command)
    Applies one committed command exactly once within a recovery generation.
    default void
    apply(long index, long term, byte[] command)
    Applies a committed command with its authoritative consensus leadership term.
    void
    restore(byte[] snapshot)
    Replaces state before replaying the suffix; implementations must validate before mutation.
    byte[]
    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 position
      command - 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 position
      term - positive term persisted in this log entry, never a caller-supplied epoch
      command - 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