Package io.microraft

Enum RaftRole

java.lang.Object
java.lang.Enum<RaftRole>
io.microraft.RaftRole
All Implemented Interfaces:
Serializable, Comparable<RaftRole>, java.lang.constant.Constable

public enum RaftRole extends Enum<RaftRole>
The roles of Raft nodes as defined in the Raft consensus algorithm.

At any given time each Raft node is in one of roles defined here.

  • Enum Constant Details

    • LEADER

      public static final RaftRole LEADER
      A leader handles client requests, commit operations and orchestrates a Raft group.
    • CANDIDATE

      public static final RaftRole CANDIDATE
      When a follower starts a new leader election, it first turns into a candidate. A candidate becomes leader if it wins the majority votes.
    • FOLLOWER

      public static final RaftRole FOLLOWER
      Followers issue no requests on their own. They respond to append-entries requests sent by leaders. Followers are also voting members. They respond to vote requests sent by candidates. They can also run queries if QueryPolicy.EVENTUAL_CONSISTENCY is used.
    • LEARNER

      public static final RaftRole LEARNER
      Learners issue no requests on their own. They only respond to append-entries requests sent by leaders. Learners are non-voting members. They do not turn into candidates and do not receive vote requests from other candidates during leader election rounds. They can also run queries if QueryPolicy.EVENTUAL_CONSISTENCY is used.
  • Method Details

    • values

      public static RaftRole[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static RaftRole valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null