T - The type of POJO associated with the future object setpublic class ListenableFutureImpl<T> extends com.google.common.util.concurrent.AbstractFuture<ObjectSet<T>>
ListenableFutureImpl class extends Cassandra's
ResultSetFuture in order to provide
support for POJOs.| Modifier and Type | Field and Description |
|---|---|
protected StatementManager.Context<T> |
context
Holds the statement context associated with this object set.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Runnable listener,
Executor exec) |
boolean |
cancel(boolean mayInterruptIfRunning)
Attempts to cancel the execution of the request corresponding to this
future.
|
ObjectSet<T> |
get() |
ObjectSet<T> |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
protected void |
postProcess(com.datastax.driver.core.ResultSet result)
Post-process the result set.
|
protected final StatementManager.Context<T> context
protected void postProcess(com.datastax.driver.core.ResultSet result)
ObjectSetImpl will be based
on what is left off in the result set after post-processing.result - the non-null result set to be post processedpublic ObjectSet<T> get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException
get in interface Future<ObjectSet<T>>get in class com.google.common.util.concurrent.AbstractFuture<ObjectSet<T>>com.datastax.driver.core.exceptions.NoHostAvailableException - if no host in the cluster can be contacted
successfully to execute this query.com.datastax.driver.core.exceptions.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.ObjectNotFoundException - if the statement is a select and the
keyspace specified doesn't existcom.datastax.driver.core.exceptions.QueryValidationException - if the query is invalid (syntax error,
unauthorized or any other validation problem).InterruptedExceptionTimeoutExceptionExecutionExceptionAbstractFuture.get(long, java.util.concurrent.TimeUnit)public ObjectSet<T> get() throws InterruptedException, ExecutionException
get in interface Future<ObjectSet<T>>get in class com.google.common.util.concurrent.AbstractFuture<ObjectSet<T>>com.datastax.driver.core.exceptions.NoHostAvailableException - if no host in the cluster can be contacted
successfully to execute this query.com.datastax.driver.core.exceptions.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.ObjectNotFoundException - if the statement is a select and the
keyspace specified doesn't existcom.datastax.driver.core.exceptions.QueryValidationException - if the query is invalid (syntax error,
unauthorized or any other validation problem).InterruptedExceptionExecutionExceptionAbstractFuture.get()public boolean cancel(boolean mayInterruptIfRunning)
Please note that this only cancel 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 object set is not going to be retried. Typically, the code to wait for a request result for a maximum of 1 second could look like:
final ObjectSetFuture<T> future = statement.executeAsync();
try {
final ObjectSet<T> 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<ObjectSet<T>>cancel in class com.google.common.util.concurrent.AbstractFuture<ObjectSet<T>>mayInterruptIfRunning - the value of this parameter is currently
ignored.false if the future could not be cancelled (it has already
completed normally); true otherwise.AbstractFuture.cancel(boolean)public boolean isDone()
public boolean isCancelled()
Copyright (C) 2015-2017 The Helenus Driver Project Authors.