Annotation Interface StateMachineField


@Target(FIELD) @Retention(RUNTIME) public @interface StateMachineField
Marks a field for inclusion in Raft snapshots.

This annotation identifies state machine fields that should be persisted when creating snapshots of the current state. Snapshots are used to compact the log and enable efficient state transfer to new or lagging nodes.

Field requirements:

  • Must not be private - accessible for snapshot operations
  • Must not be final - modifiable during snapshot restoration
  • Must be thread-safe - concurrent access during snapshot creation

The order parameter determines the sequence in which fields are stored and restored in snapshots, ensuring consistent state reconstruction.

Since:
2.0
Author:
José Bolina
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    int
    The order of the field to be stored in the snapshot.
  • Element Details

    • order

      int order
      The order of the field to be stored in the snapshot.

      The fields guarantee the order in which they are stored in the snapshot. This value must be unique across all fields in the state machine. If multiple fields have the same order, an IllegalStateException will be thrown.

      Returns:
      The order of the field in the snapshot.