Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *      Copyright (C) 2012 DataStax Inc.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  *   Unless required by applicable law or agreed to in writing, software
  *   distributed under the License is distributed on an "AS IS" BASIS,
  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  */
 package com.datastax.driver.core;
 
 import java.util.List;

Basic information on the execution of a query.

This provides the following information on the execution of a (successful) query:

  • The list of Cassandra hosts tried in order (usually just one, unless a node has been tried but was dead/in error or a timeout provoked a retry (which depends on the RetryPolicy)).
  • The consistency level achieved by the query (usually the one asked, though some specific RetryPolicy may allow this to be different).
  • The query trace recorded by Cassandra if tracing had been set for the query.
 
 public class ExecutionInfo
 {
     private final List<HosttriedHosts;
     private final ConsistencyLevel achievedConsistency;
     private final QueryTrace trace;
 
     private ExecutionInfo(List<HosttriedHostsConsistencyLevel achievedConsistencyQueryTrace trace) {
         this. = triedHosts;
         this. = achievedConsistency;
         this. = trace;
     }
 
     ExecutionInfo(List<HosttriedHosts) {
         this(triedHostsnullnull);
     }
 
     ExecutionInfo withTrace(QueryTrace newTrace) {
         return new ExecutionInfo(newTrace);
     }
 
         return new ExecutionInfo(newConsistency);
     }

    
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 an host is tried by the driver but is dead or in error, that host is recorded and the query is retry. Also, on a timeout or unavailable exception, some com.datastax.driver.core.policies.RetryPolicy may retry the query on the same host, so the same host might appear twice.

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.
 
     public List<HostgetTriedHosts() {
         return ;
     }

    
Return the Cassandra host that coordinated this query.

This is a shortcut for getTriedHosts().get(getTriedHosts().size()).

Returns:
return the Cassandra host that coordinated this query.
 
     public Host getQueriedHost() {
         return .get(.size() - 1);
     }

    
If the query returned without achieving the requested consistency level due to the com.datastax.driver.core.policies.RetryPolicy, this return the biggest consistency level that has been actually achieved by the query.

Note that the default RetryPolicy (com.datastax.driver.core.policies.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 return null. However, it might occasionally return a non-null with say, com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy.

Returns:
null if the original consistency level of the query was achieved, or the consistency level that was ultimately achieved if the RetryPolicy triggered a retry at a different consistency level than the original one.
        return ;
    }

    
The query trace if tracing was enabled on this query.

Returns:
the QueryTrace object for this query if tracing was enable for this query, or null otherwise.
    public QueryTrace getQueryTrace() {
        return ;
    }
New to GrepCode? Check out our FAQ X