Enum Class RaftServer.Role
- All Implemented Interfaces:
Serializable,Comparable<RaftServer.Role>,Constable
- Enclosing interface:
RaftServer
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 ConstantsEnum ConstantDescriptionRepresents 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 TypeMethodDescriptionbooleanactive()Returns whether the role is a voting Raft member role.static RaftServer.RoleReturns the enum constant of this class with the specified name.static RaftServer.Role[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INACTIVE
Represents the state of an inactive server.All servers start in this state.
-
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
Represents the state of a server in the process of being promoted to an active voting member. -
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
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
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
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
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 nameNullPointerException- 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
-