Class ExecutionInfo
- java.lang.Object
-
- com.datastax.driver.core.ExecutionInfo
-
public class ExecutionInfo extends Object
Basic information on the execution of a query.
-
-
Constructor Summary
Constructors Constructor Description ExecutionInfo(int speculativeExecutions, int successfulExecutionIndex, List<Host> triedHosts, ConsistencyLevel achievedConsistency, Map<String,ByteBuffer> customPayload)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsistencyLevelgetAchievedConsistencyLevel()If the query returned without achieving the requested consistency level due to theRetryPolicy, this return the biggest consistency level that has been actually achieved by the query.Map<String,ByteBuffer>getIncomingPayload()Return the incoming payload, that is, the payload that the server sent back with its response, if any, ornull, if the server did not include any custom payload.PagingStategetPagingState()The paging state of the query.byte[]getPagingStateUnsafe()Returns the "raw" paging state of the query.HostgetQueriedHost()Return the Cassandra host that coordinated this query.QueryTracegetQueryTrace()Return the query trace if tracing was enabled on this query.ListenableFuture<QueryTrace>getQueryTraceAsync()Placeholder for async query trace retrieval (not implemented yet).intgetSpeculativeExecutions()The number of speculative executions that were started for this query.StatementgetStatement()Get the statement that has been executed.intgetSuccessfulExecutionIndex()The index of the execution that completed this query.List<Host>getTriedHosts()The list of tried hosts for this query.List<String>getWarnings()Returns the server-side warnings for this query.booleanisSchemaInAgreement()Whether the cluster had reached schema agreement after the execution of this query.
-
-
-
Constructor Detail
-
ExecutionInfo
public ExecutionInfo(int speculativeExecutions, int successfulExecutionIndex, List<Host> triedHosts, ConsistencyLevel achievedConsistency, Map<String,ByteBuffer> customPayload)
-
-
Method Detail
-
getTriedHosts
public List<Host> getTriedHosts()
The list of tried hosts for this query.In general, this will be a singleton list with the host that coordinated that query. However:
- if a host is tried by the driver but is dead or in error, that host is recorded and the query is retried;
- on a timeout or unavailable exception, some
RetryPolicymay retry the query on the same host, so the same host might appear twice. - if
speculative executionsare enabled, this will also contain hosts that were tried by other executions (however, note that this only contains hosts which timed out, or for which a response was received; if an execution is waiting for a response from a host and another execution completes the request in the meantime, then the host of the first execution will not be in that list).
If you are only interested in fetching the final (and often only) node coordinating the query,
getQueriedHost()provides a shortcut to fetch the last element of the list returned by this method.- Returns:
- the list of tried hosts for this query, in the order tried.
-
getQueriedHost
public Host getQueriedHost()
Return the Cassandra host that coordinated this query.This is a shortcut for
getTriedHosts().get(getTriedHosts().size() - 1).- Returns:
- return the Cassandra host that coordinated this query.
-
getSpeculativeExecutions
public int getSpeculativeExecutions()
The number of speculative executions that were started for this query.This does not include the initial, normal execution of the query. Therefore, if speculative executions are disabled, this will always be 0. If they are enabled and one speculative execution was triggered in addition to the initial execution, this will be 1, etc.
-
getSuccessfulExecutionIndex
public int getSuccessfulExecutionIndex()
The index of the execution that completed this query.0 represents the initial, normal execution of the query, 1 represents the first speculative execution, etc.
-
getAchievedConsistencyLevel
public ConsistencyLevel getAchievedConsistencyLevel()
If the query returned without achieving the requested consistency level due to theRetryPolicy, this return the biggest consistency level that has been actually achieved by the query.Note that the default
RetryPolicy(DefaultRetryPolicy) will never allow a query to be successful without achieving the initially requested consistency level and hence with that default policy, this method will always returnnull. However, it might occasionally return a non-nullwith say,DowngradingConsistencyRetryPolicy.- Returns:
nullif the original consistency level of the query was achieved, or the consistency level that was ultimately achieved if theRetryPolicytriggered a retry at a different consistency level than the original one.
-
getQueryTrace
public QueryTrace getQueryTrace()
Return the query trace if tracing was enabled on this query.Note that accessing the fields of the the returned object will trigger a blocking background query.
- Returns:
- the
QueryTraceobject for this query if tracing was enable for this query, ornullotherwise.
-
getQueryTraceAsync
public ListenableFuture<QueryTrace> getQueryTraceAsync()
Placeholder for async query trace retrieval (not implemented yet).Async query trace retrieval will be implemented in a future version. This method is added now to avoid breaking binary compatibility later. The current implementation merely wraps the result of
getQueryTrace()in an immediate future; it will still trigger a blocking query when the query trace's fields are accessed.- Returns:
- currently, an immediate future containing the result of
getQueryTrace().
-
getPagingState
public PagingState getPagingState()
The paging state of the query.This object represents the next page to be fetched if this query is multi page. It can be saved and reused later on the same statement.
- Returns:
- the paging state or null if there is no next page.
- See Also:
Statement.setPagingState(PagingState)
-
getPagingStateUnsafe
public byte[] getPagingStateUnsafe()
Returns the "raw" paging state of the query.Contrary to
getPagingState(), there will be no validation when this is later reinjected into a statement.- Returns:
- the paging state or null if there is no next page.
- See Also:
Statement.setPagingStateUnsafe(byte[])
-
isSchemaInAgreement
public boolean isSchemaInAgreement()
Whether the cluster had reached schema agreement after the execution of this query.After a successful schema-altering query (ex: creating a table), the driver will check if the cluster's nodes agree on the new schema version. If not, it will keep retrying for a given delay (configurable via
Cluster.Builder.withMaxSchemaAgreementWaitSeconds(int)).If this method returns
false, clients can callMetadata.checkSchemaAgreement()later to perform the check manually.Note that the schema agreement check is only performed for schema-altering queries For other query types, this method will always return
true.- Returns:
- whether the cluster reached schema agreement, or
truefor a non schema-altering statement.
-
getWarnings
public List<String> getWarnings()
Returns the server-side warnings for this query.This feature is only available with
ProtocolVersion.V4or above; with lower versions, the returned list will always be empty.- Returns:
- the warnings, or an empty list if there are none.
- Since:
- 2.2
-
getIncomingPayload
public Map<String,ByteBuffer> getIncomingPayload()
Return the incoming payload, that is, the payload that the server sent back with its response, if any, ornull, if the server did not include any custom payload.This method returns a read-only view of the original map, but its values remain inherently mutable. Callers should take care not to modify the returned map in any way.
This feature is only available with
ProtocolVersion.V4or above; with lower versions, this method will always returnnull.- Returns:
- the custom payload that the server sent back with its response, if any, or
null, if the server did not include any custom payload. - Since:
- 2.2
-
getStatement
public Statement getStatement()
Get the statement that has been executed.- Returns:
- the statement executed.
-
-