Annotation Interface StateMachineRead


@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface StateMachineRead
Marks a method as a read-only operation in the Raft state machine.

Read operations do not modify the state machine and can be executed locally without going through the consensus protocol. This provides better performance for queries that don't require strong consistency. Read-only operations also employ the optimization described in the Raft paper to ensure linearizability by checking the leader's commit index, in case linearizability is required.

Each read operation must be uniquely identifiable within the state machine class by its id and version combination. The same id/version pair cannot be shared between read operations.

The version parameter enables backwards compatibility when evolving the state machine interface over time.

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

    Required Elements
    Modifier and Type
    Required Element
    Description
    int
    Unique identifier for this read operation within the state machine definition.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    Version number for backwards compatibility.
  • Element Details

    • id

      int id
      Unique identifier for this read operation within the state machine definition.
      Returns:
      the operation identifier
    • version

      int version
      Version number for backwards compatibility.

      Allows evolution of the state machine interface while maintaining compatibility with existing clients.

      Returns:
      the operation version, defaults to 1
      Default:
      1