Enum Class JGroupsRaftRole

java.lang.Object
java.lang.Enum<JGroupsRaftRole>
org.jgroups.raft.JGroupsRaftRole
All Implemented Interfaces:
Serializable, Comparable<JGroupsRaftRole>, Constable

public enum JGroupsRaftRole extends Enum<JGroupsRaftRole>
Represents the role of a Raft node.

Nodes can transition between the following roles:

    NONE ──┬── LEARNER
           │
           └── FOLLOWER ──── LEADER
                   ↑           │
                   └───────────┘

- NONE: Node not initialized or stopped
- LEARNER: Node connects but not in membership list
- FOLLOWER: Node connects and is in membership list
- LEADER: Elected from FOLLOWER role

Since:
2.0
Author:
José Bolina
  • Enum Constant Details

    • NONE

      public static final JGroupsRaftRole NONE
      Indicates no active role.

      This state occurs when the Raft node is not initialized, has been stopped (JGroupsRaft.stop()), or is in a transitional state before assuming an active role after calling JGroupsRaft.start().

    • LEADER

      public static final JGroupsRaftRole LEADER
      The leader role in the Raft consensus algorithm.

      The leader is responsible for accepting client requests, replicating log entries to followers, and coordinating the consensus process. Only one leader exists per term in a functioning cluster. JGroups Raft handles leader election through View changes in JGroups. Therefore, there are no competing candidates or timeouts for starting elections. You can learn more about the implementation in design documents.

    • FOLLOWER

      public static final JGroupsRaftRole FOLLOWER
      The follower role in the Raft consensus algorithm.

      Followers passively receive and acknowledge log entries from the leader, participate in leader elections, and can become candidates when the leader becomes unavailable.

    • LEARNER

      public static final JGroupsRaftRole LEARNER
      The learner role as described in Raft optimizations.

      Learners receive log entries from the leader but do not participate in voting or consensus decisions. This role is typically used for nodes that need to catch up on the log or for read-only replicas. Every node that joins the cluster and is not in the Raft membership is considered a learner. This approach allows for dynamic scaling of the cluster without affecting the quorum required for consensus. The node can be promoted to a full member of the Raft cluster by updating the Raft configuration to include it in the membership after it has caught up with all changes. You can learn more about the implementation in design documents.

  • Method Details

    • values

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

      public static JGroupsRaftRole valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null