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() |
default Partitioner |
getPartitioner()
The partitioner to use for token-aware routing.
|
ByteBuffer |
getRoutingKey()
The partition key to use for token-aware routing.
|
CqlIdentifier |
getRoutingKeyspace()
The keyspace to use for token-aware routing.
|
Token |
getRoutingToken()
The token to use for 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()
Note that if a per-request keyspace is already defined for this request, it takes precedence over this method.
See getRoutingKey()
for a detailed explanation of token-aware routing.
@Nullable ByteBuffer getRoutingKey()
For each request, the driver tries to determine a routing keyspace and a routing key by calling the following methods:
getKeyspace()
, if not null;
getRoutingKeyspace()
, if not null;
Session.getKeyspace()
, if not empty;
getRoutingToken()
, if not null;
getRoutingKey()
, if not null;
Routing information is optional: if either keyspace or key is null, token-aware routing is disabled for this request.
@Nullable Token getRoutingToken()
This is an alternative to getRoutingKey()
. Both methods represent the same
information, a request can provide one or the other.
See getRoutingKey()
for a detailed explanation of token-aware routing.
default Partitioner getPartitioner()
null
, the cluster-wide partitioner
will be used.@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–2024. All rights reserved.