Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Attempts to cancel the execution of the request corresponding to this
future.
|
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.
|
public ResultSet getUninterruptibly()
AbstractFuture.get(long, java.util.concurrent.TimeUnit)
because it:
InterruptedException
.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).public ResultSet getUninterruptibly(long timeout, TimeUnit unit) throws TimeoutException
AbstractFuture.get(long, java.util.concurrent.TimeUnit)
because it:
InterruptedException
.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
).public boolean cancel(boolean mayInterruptIfRunning)
Please note that this only cancle the request driver side, but nothing
is done to interrupt the execution of the request Cassandra side (and that even
if mayInterruptIfRunning
is true) since Cassandra does not
support such interruption.
This method can be used to ensure no more work is performed driver side (which, while it doesn't include stopping a request already submitted to a Cassandra node, may include not retrying another Cassandra host on failure/timeout) if the ResultSet is not going to be retried. Typically, the code to wait for a request result for a maximum of 1 second could look like:
ResultSetFuture future = session.executeAsync(...some query...); try { ResultSet result = future.get(1, TimeUnit.SECONDS); ... process result ... } catch (TimeoutException e) { future.cancel(true); // Ensure any ressource used by this query driver // side is released immediately ... handle timeout ... }
cancel
in interface Future<ResultSet>
cancel
in class com.google.common.util.concurrent.AbstractFuture<ResultSet>
mayInterruptIfRunning
- the value of this parameter is currently
ignored.false
if the future could not be cancelled (it has already
completed normally); true
otherwise.public boolean set(V value)
true
if
the value was successfully set, or false
if the future has already
been set or cancelled.set
in class com.google.common.util.concurrent.AbstractFuture<V>
value
- the value the future should hold.public boolean setException(Throwable throwable)
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.setException
in class com.google.common.util.concurrent.AbstractFuture<V>
throwable
- the exception the future should hold.Copyright © 2013. All Rights Reserved.