public enum ReadConsistency extends Enum<ReadConsistency>
Read consistency levels dictate how queries should be evaluated in the Atomix cluster. Resources generally have significantly greater flexibility in controlling the consistency level of reads because Raft allows reads from leaders or followers. Consistency levels can be applied on a per-command basis or to all operations for a given resource.
| Enum Constant and Description |
|---|
ATOMIC
Guarantees atomicity (linearizability) for read operations.
|
ATOMIC_LEASE
Provides linearizability under a leader lease.
|
SEQUENTIAL
Guarantees sequential consistency for read operations.
|
| Modifier and Type | Method and Description |
|---|---|
Query.ConsistencyLevel |
level() |
static ReadConsistency |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ReadConsistency[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ReadConsistency ATOMIC
The atomic consistency level guarantees linearizability 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 final ReadConsistency ATOMIC_LEASE
Atomic lease consistency 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 ATOMIC consistency.
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 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 ReadConsistency[] values()
for (ReadConsistency c : ReadConsistency.values()) System.out.println(c);
public static ReadConsistency 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 nullpublic Query.ConsistencyLevel level()
Copyright © 2013–2016. All rights reserved.