com.datastax.driver.core
Class ResultSetFuture

java.lang.Object
  extended by com.google.common.util.concurrent.AbstractFuture<V>
      extended by com.datastax.driver.core.ResultSetFuture
All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<ResultSet>, Future<ResultSet>

public class ResultSetFuture
extends com.google.common.util.concurrent.AbstractFuture<V>

A future on a ResultSet. Note that this class implements Guava's ListenableFuture and can so be used with Guava's future utilities.


Method Summary
 ResultSet getUninterruptibly()
          Waits for the query to return and return its result.
 ResultSet getUninterruptibly(long timeout, TimeUnit unit)
          Waits for the provided time for the query to return and return its result if available.
 boolean set(V value)
          Sets the value of this future.
 boolean setException(Throwable throwable)
          Sets the future to having failed with the given exception.
 
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, cancel, get, get, interruptTask, isCancelled, isDone, wasInterrupted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUninterruptibly

public ResultSet getUninterruptibly()
Waits for the query to return and return its result. This method is usually more convenient than AbstractFuture.get(long, java.util.concurrent.TimeUnit) because it: As such, it is the preferred way to get the future result.

Throws:
NoHostAvailableException - if no host in the cluster can be contacted successfully to execute this query.
QueryExecutionException - if the query triggered an execution exception, that is an exception thrown by Cassandra when it cannot execute the query with the requested consistency level successfully.
QueryValidationException - if the query is invalid (syntax error, unauthorized or any other validation problem).

getUninterruptibly

public ResultSet getUninterruptibly(long timeout,
                                    TimeUnit unit)
                             throws TimeoutException
Waits for the provided time for the query to return and return its result if available. This method is usually more convenient than AbstractFuture.get(long, java.util.concurrent.TimeUnit) because it: As such, it is the preferred way to get the future result.

Throws:
NoHostAvailableException - if no host in the cluster can be contacted successfully to execute this query.
QueryExecutionException - if the query triggered an execution exception, that is an exception thrown by Cassandra when it cannot execute the query with the requested consistency level successfully.
QueryValidationException - if the query if invalid (syntax error, unauthorized or any other validation problem).
TimeoutException - if the wait timed out (Note that this is different from a Cassandra timeout, which is a QueryExecutionException).

set

public boolean set(V value)
Sets the value of this future. This method will return true if the value was successfully set, or false if the future has already been set or cancelled.

Overrides:
set in class com.google.common.util.concurrent.AbstractFuture<V>
Parameters:
value - the value the future should hold.
Returns:
true if the value was successfully set.

setException

public boolean setException(Throwable throwable)
Sets the future to having failed with the given exception. This exception will be wrapped in an ExecutionException and thrown from the get methods. This method will return true if the exception was successfully set, or false if the future has already been set or cancelled.

Overrides:
setException in class com.google.common.util.concurrent.AbstractFuture<V>
Parameters:
throwable - the exception the future should hold.
Returns:
true if the exception was successfully set.


Copyright © 2013. All Rights Reserved.