Package io.microraft
Enum RaftRole
- java.lang.Object
-
- java.lang.Enum<RaftRole>
-
- io.microraft.RaftRole
-
- All Implemented Interfaces:
Serializable
,Comparable<RaftRole>
public enum RaftRole extends Enum<RaftRole>
The roles of Raft nodes as defined in the Raft consensus algorithm.At any given time each Raft node is in one of roles defined here.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CANDIDATE
When a follower starts a new leader election, it first turns into a candidate.FOLLOWER
Followers issue no requests on their own.LEADER
A leader handles client requests, commit operations and orchestrates a Raft group.LEARNER
Learners issue no requests on their own.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RaftRole
valueOf(String name)
Returns the enum constant of this type with the specified name.static RaftRole[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
LEADER
public static final RaftRole LEADER
A leader handles client requests, commit operations and orchestrates a Raft group.
-
CANDIDATE
public static final RaftRole CANDIDATE
When a follower starts a new leader election, it first turns into a candidate. A candidate becomes leader if it wins the majority votes.
-
FOLLOWER
public static final RaftRole FOLLOWER
Followers issue no requests on their own. They respond to append-entries requests sent by leaders. Followers are also voting members. They respond to vote requests sent by candidates. They can also run queries ifQueryPolicy.EVENTUAL_CONSISTENCY
orQueryPolicy.BOUNDED_STALENESS
is used.
-
LEARNER
public static final RaftRole LEARNER
Learners issue no requests on their own. They only respond to append-entries requests sent by leaders. Learners are non-voting members. They do not turn into candidates and do not receive vote requests from other candidates during leader election rounds. They can also run queries ifQueryPolicy.EVENTUAL_CONSISTENCY
orQueryPolicy.BOUNDED_STALENESS
is used.
-
-
Method Detail
-
values
public static RaftRole[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RaftRole c : RaftRole.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RaftRole valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
-