public static enum Query.ConsistencyLevel extends Enum<Query.ConsistencyLevel>
Query consistency levels.
This enum provides identifiers for configuring consistency levels for queries
submitted to a Raft cluster.
Consistency levels are used to dictate how queries are routed through the Raft cluster and the requirements for completing read operations based on submitted queries. For expectations of specific consistency levels, see below.
| Enum Constant and Description |
|---|
LINEARIZABLE
Enforces linearizable query consistency.
|
LINEARIZABLE_LEASE
Enforces linearizable query consistency based on leader lease.
|
SEQUENTIAL
Enforces sequential query consistency.
|
| Modifier and Type | Method and Description |
|---|---|
static Query.ConsistencyLevel |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Query.ConsistencyLevel[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Query.ConsistencyLevel SEQUENTIAL
Sequential read consistency requires that clients always see state progress in monotonically increasing order. Note that
this constraint allows reads from followers. When a sequential Query is submitted to the cluster, the first
server that receives the query will handle it. However, in order to ensure that state does not go back in time, the
client must submit its last known index with the query as well. If the server that receives the query has not advanced
past the provided client index, it will queue the query and await more entries from the leader.
public static final Query.ConsistencyLevel LINEARIZABLE_LEASE
Bounded linearizability is a special implementation of linearizable reads that relies on the semantics of Raft's
election timers to determine whether it is safe to immediately apply a query to the Raft state machine. When a
linearizable Query is submitted to the Raft cluster with linearizable consistency,
it must be forwarded to the current cluster leader. For lease-based linearizability, the leader will determine whether
it's safe to apply the query to its state machine based on the last time it successfully contacted a majority of the
cluster. If the leader contacted a majority of the cluster within the last election timeout, it assumes that no other
member could have since become the leader and immediately applies the query to its state machine. Alternatively, if it
hasn't contacted a majority of the cluster within an election timeout, the leader will handle the query as if it were
submitted with LINEARIZABLE consistency.
public static final Query.ConsistencyLevel LINEARIZABLE
The linearizable consistency level guarantees consistency by contacting a majority of the cluster on every read.
When a Query is submitted to the cluster with linearizable consistency, it must be
forwarded to the current cluster leader. Once received by the leader, the leader will contact a majority of the
cluster before applying the query to its state machine and returning the result. Note that if the leader is already
in the process of contacting a majority of the cluster, it will queue the Query to
be processed on the next round trip. This allows the leader to batch expensive quorum based reads for efficiency.
public static Query.ConsistencyLevel[] values()
for (Query.ConsistencyLevel c : Query.ConsistencyLevel.values()) System.out.println(c);
public static Query.ConsistencyLevel 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–2017. All rights reserved.