public interface Query<T> extends Operation<T>
Queries are submitted by clients to a Raft server to read Raft cluster-wide state. In contrast to
commands, queries allow for more flexible consistency levels that trade
consistency for performance.
consistency() with which to execute the query. The provided consistency level
dictates how queries are submitted to the Raft cluster. When a query is submitted to the cluster, the query is
sent in a message to the server to which the client is currently connected. The server handles the query requests
based on the configured Query.ConsistencyLevel. For Query.ConsistencyLevel.SEQUENTIAL consistency, followers
are allowed to execute queries with certain constraints for faster reads. For higher consistency levels like
Query.ConsistencyLevel.LINEARIZABLE and Query.ConsistencyLevel.LINEARIZABLE_LEASE, queries are forwarded to the
cluster leader. See the Query.ConsistencyLevel documentation for more info.
By default, all queries should use the strongest consistency level, Query.ConsistencyLevel.LINEARIZABLE.
It is essential that users understand the trade-offs in the various consistency levels before using them.
CatalystSerializable
or register a custom TypeSerializer for better performance. Serializable types
can be registered on the associated client/server Serializer instance.Query.ConsistencyLevel| Modifier and Type | Interface and Description |
|---|---|
static class |
Query.ConsistencyLevel
Constants for specifying Raft
Query consistency levels. |
| Modifier and Type | Method and Description |
|---|---|
default Query.ConsistencyLevel |
consistency()
Returns the query consistency level.
|
default Query.ConsistencyLevel consistency()
The consistency will dictate how the query is executed on the server state. Stronger consistency levels can guarantee
linearizability in all or most cases, while weaker consistency levels trade linearizability for more performant
reads from followers. Consult the Query.ConsistencyLevel documentation for more information
on the different consistency levels.
By default, this method enforces strong consistency with the Query.ConsistencyLevel.LINEARIZABLE consistency level.
Copyright © 2013–2016. All rights reserved.