public enum ReadConsistency extends Enum<ReadConsistency>
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|
Enforces linearizable query consistency.
Enforces linearizable query consistency based on leader lease.
Enforces sequential query consistency.
|Modifier and Type||Method and Description|
Returns the enum constant of this type with the specified name.
Returns an array containing the constants of this enum type, in the order they are declared.
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
public static final ReadConsistency 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
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 ReadConsistency 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
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
public static final ReadConsistency LINEARIZABLE
The linearizable consistency level guarantees consistency by contacting a majority of the cluster on every read.
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 ReadConsistency values()
for (ReadConsistency c : ReadConsistency.values()) System.out.println(c);
public static ReadConsistency valueOf(String name)
Copyright © 2013–2018. All rights reserved.