public interface Request
Session
.
This is a high-level abstraction, agnostic to the actual language (e.g. CQL). A request is anything that can be converted to a protocol message, provided that you register a request processor with the driver to do that conversion.
Modifier and Type | Method and Description |
---|---|
Map<String,ByteBuffer> |
getCustomPayload()
Returns the custom payload to send alongside the request.
|
DriverExecutionProfile |
getExecutionProfile()
The execution profile to use for this request, or
null if no profile has been set. |
String |
getExecutionProfileName()
The name of the execution profile that will be used for this request, or
null if no
profile has been set. |
CqlIdentifier |
getKeyspace()
The CQL keyspace to execute this request in, or
null if this request does not specify
any keyspace. |
Node |
getNode() |
ByteBuffer |
getRoutingKey()
The (encoded) partition key to use for token-aware routing, or
null if this request
does not use token-aware routing. |
CqlIdentifier |
getRoutingKeyspace()
The keyspace to use for token-aware routing, if no
per-request keyspace
is defined, or null if this request does not use token-aware routing. |
Token |
getRoutingToken()
The token to use for token-aware routing, or
null if this request does not use
token-aware routing. |
Duration |
getTimeout()
How long to wait for this request to complete.
|
Boolean |
isIdempotent()
Whether the request is idempotent; that is, whether applying the request twice leaves the
database in the same state.
|
@Nullable String getExecutionProfileName()
null
if no
profile has been set.
Note that this will be ignored if getExecutionProfile()
returns a non-null value.
DriverConfig
@Nullable DriverExecutionProfile getExecutionProfile()
null
if no profile has been set.
It is generally simpler to specify a profile name with getExecutionProfileName()
.
However, this method can be used to provide a "derived" profile that was built programmatically
by the client code. If specified, it overrides the profile name.
DriverExecutionProfile
@Nullable CqlIdentifier getKeyspace()
null
if this request does not specify
any keyspace.
This overrides Session.getKeyspace()
for this particular request, providing a way to
specify the keyspace without forcing it globally on the session, nor hard-coding it in the
query string.
This feature is only available with native protocol v5
or
higher. Specifying a per-request keyspace with lower protocol versions will cause a runtime
error.
@Nullable CqlIdentifier getRoutingKeyspace()
per-request keyspace
is defined, or null
if this request does not use token-aware routing.
See getRoutingKey()
for a detailed explanation of token-aware routing.
Note that this is the only way to define a routing keyspace for protocol v4 or lower.
@Nullable ByteBuffer getRoutingKey()
null
if this request
does not use token-aware routing.
When the driver picks a coordinator to execute a request, it prioritizes the replicas of the partition that this query operates on, in order to avoid an extra network jump on the server side. To find these replicas, it needs a keyspace (which is where the replication settings are defined) and a key, that are computed the following way:
getKeyspace()
, it is used as the
keyspace;
getRoutingKeyspace()
is specified, it is used as the keyspace;
Session.getKeyspace()
is not null
, it is used as the
keyspace;
getRoutingToken()
, it is used as the key;
null
at the end of this process, then token-aware routing
is disabled.@Nullable Token getRoutingToken()
null
if this request does not use
token-aware routing.
This is the same information as getRoutingKey()
, but already hashed in a token. It
is probably more useful for analytics tools that "shard" a query on a set of token ranges.
See getRoutingKey()
for a detailed explanation of token-aware routing.
@NonNull Map<String,ByteBuffer> getCustomPayload()
This is used to exchange extra information with the server. By default, Cassandra doesn't do anything with this, you'll only need it if you have a custom request handler on the server-side.
@Nullable Boolean isIdempotent()
This is used internally for retries and speculative executions: if a request is not idempotent, the driver will take extra care to ensure that it is not sent twice (for example, don't retry if there is the slightest chance that the request reached a coordinator).
null
to use the default value defined in the configuration.DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE
@Nullable Duration getTimeout()
null
to use the default value defined in the
configuration.DefaultDriverOption.REQUEST_TIMEOUT
@Nullable Node getNode()
Copyright © 2017–2019. All rights reserved.