Package io.microraft

Enum RaftRole

  • All Implemented Interfaces:
    Serializable, Comparable<RaftRole>

    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 Detail

      • 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.
      • 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 or QueryPolicy.BOUNDED_STALENESS is used.
    • Method Detail

      • values

        public static RaftRole[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (RaftRole c : RaftRole.values())
            System.out.println(c);
        
        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