public static enum RaftServer.Role extends Enum<RaftServer.Role>
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.
| Enum Constant and Description |
|---|
CANDIDATE
Represents the state of a server attempting to become the leader.
|
FOLLOWER
Represents the state of a server participating in normal log replication.
|
INACTIVE
Represents the state of an inactive server.
|
LEADER
Represents the state of a server which is actively coordinating and replicating logs with other servers.
|
PASSIVE
Represents the state of a server in the process of catching up its log.
|
PROMOTABLE
Represents the state of a server in the process of being promoted to an active voting member.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
active()
Returns whether the role is a voting Raft member role.
|
static RaftServer.Role |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RaftServer.Role[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RaftServer.Role INACTIVE
All servers start in this state and return to this state when stopped.
public static final RaftServer.Role PASSIVE
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.
public static final RaftServer.Role PROMOTABLE
public static final RaftServer.Role FOLLOWER
The follower state is a standard Raft state in which the server receives replicated log entries from the leader.
public static final RaftServer.Role CANDIDATE
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.
public static final RaftServer.Role LEADER
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 RaftCluster.getTerm().
public static RaftServer.Role[] values()
for (RaftServer.Role c : RaftServer.Role.values()) System.out.println(c);
public static RaftServer.Role valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic boolean active()
Copyright © 2013–2017. All rights reserved.