Enum QueryPolicy
- All Implemented Interfaces:
Serializable
,Comparable<QueryPolicy>
,java.lang.constant.Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionRuns the query on the local state machine of any Raft node.Runs the query on the local state machine of the leader Raft node.Runs the query in a linearizable manner on the leader Raft node by using the algorithm defined in the Section: 6.4 Processing read-only queries more efficiently of the Raft dissertation. -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryPolicy
Returns the enum constant of this type with the specified name.static QueryPolicy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
EVENTUAL_CONSISTENCY
Runs the query on the local state machine of any Raft node.Reading stale value is likely if queries are issued on follower or learner Raft nodes while the leader Raft node is committing new operations.
Callers can achieve monotonic reads by keeping track of highest commit index they observed via return values of RaftNode's methods and passing it to queries. In this case, RaftNode executes a given query only if its local commit index is greater than equal to the given commit index.
-
LEADER_LEASE
Runs the query on the local state machine of the leader Raft node.The leader Raft node executes a given query operation with this policy only if it has received AppendEntries RPC responses from the majority of the Raft group in the last leader heartbeat duration.
This policy is much more likely to hit more recent state when compared to the
EVENTUAL_CONSISTENCY
policy. However, it cannot guarantee linearizability since other Raft nodes' clocks may move forward in time and they can elect a new leader among themselves while the old leader still considers itself as the leader. -
LINEARIZABLE
Runs the query in a linearizable manner on the leader Raft node by using the algorithm defined in the Section: 6.4 Processing read-only queries more efficiently of the Raft dissertation. In short, linearizable queries are handled via a round of AppendEntries RPC between the leader and others without appending an entry to the internal Raft log.Since, a given query is executed by the leader Raft node for both
LEADER_LEASE
and this policy, both policies have the same processing cost. However, this policy guarantees linearizability with an extra cost of 1 RTT latency overhead compared to theLEADER_LEASE
policy.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
-