public static enum CopycatServer.State extends Enum<CopycatServer.State>
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.
|
RESERVE
Represents the state of a server that is a reserve member of the cluster.
|
| Modifier and Type | Method and Description |
|---|---|
static CopycatServer.State |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static CopycatServer.State[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CopycatServer.State INACTIVE
All servers start in this state and return to this state when stopped.
public static final CopycatServer.State RESERVE
Reserve servers only receive notification of leader, term, and configuration changes.
public static final CopycatServer.State 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 CopycatServer.State FOLLOWER
The follower state is a standard Raft state in which the server receives replicated log entries from the leader.
public static final CopycatServer.State 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 CopycatServer.State 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 Cluster.term().
public static CopycatServer.State[] values()
for (CopycatServer.State c : CopycatServer.State.values()) System.out.println(c);
public static CopycatServer.State 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 nullCopyright © 2013–2016. All rights reserved.