Enum Class RaftServer.Role

java.lang.Object
java.lang.Enum<RaftServer.Role>
io.atomix.raft.RaftServer.Role
All Implemented Interfaces:
Serializable, Comparable<RaftServer.Role>, Constable
Enclosing interface:
RaftServer

public static enum RaftServer.Role extends Enum<RaftServer.Role>
Raft server state types.

States represent the context of the server's internal state machine. Throughout the lifetime of a server, the server will periodically transition between states based on requests, responses, and timeouts.

Author:
Jordan Halterman
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Represents the state of a server attempting to become the leader.
    Represents the state of a server participating in normal log replication.
    Represents the state of an inactive server.
    Represents the state of a server which is actively coordinating and replicating logs with other servers.
    Represents the state of a server in the process of catching up its log.
    Represents the state of a server in the process of being promoted to an active voting member.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether the role is a voting Raft member role.
    boolean
     
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • INACTIVE

      public static final RaftServer.Role INACTIVE
      Represents the state of an inactive server.

      All servers start in this state.

    • PASSIVE

      public static final RaftServer.Role PASSIVE
      Represents the state of a server in the process of catching up its log.

      Upon successfully joining an existing cluster, the server will transition to the passive state and remain there until the leader determines that the server has caught up enough to be promoted to a full member.

    • PROMOTABLE

      public static final RaftServer.Role PROMOTABLE
      Represents the state of a server in the process of being promoted to an active voting member.
    • FOLLOWER

      public static final RaftServer.Role FOLLOWER
      Represents the state of a server participating in normal log replication.

      The follower state is a standard Raft state in which the server receives replicated log entries from the leader.

    • CANDIDATE

      public static final RaftServer.Role CANDIDATE
      Represents the state of a server attempting to become the leader.

      When a server in the follower state fails to receive communication from a valid leader for some time period, the follower will transition to the candidate state. During this period, the candidate requests votes from each of the other servers in the cluster. If the candidate wins the election by receiving votes from a majority of the cluster, it will transition to the leader state.

    • LEADER

      public static final RaftServer.Role LEADER
      Represents the state of a server which is actively coordinating and replicating logs with other servers.

      Leaders are responsible for handling and replicating writes from clients. Note that more than one leader can exist at any given time, but Raft guarantees that no two leaders will exist for the same term.

  • Method Details

    • values

      public static RaftServer.Role[] 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 RaftServer.Role 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
    • active

      public boolean active()
      Returns whether the role is a voting Raft member role.
      Returns:
      whether the role is a voting member
    • isLeader

      public boolean isLeader()