public interface RiakFuture<V,T> extends Future<V>
All Riak operations are asynchronous. It means when you execute an operation on
the cluster it will return immediately with no guarantee that the requested
operation has been completed at the end of the call. Instead, you will be returned
a RiakFuture instance which gives you the information about the result
or status of the operation.
A RiakFuture is either uncompleted or completed. When an operation begins, a new future
object is created. The new future is uncompleted initially - it is neither
succeeded, failed, nor canceled because the operation is not finished yet.
If the operation is finished either successfully, with failure, or by cancellation,
the future is marked as completed with more specific information, such as the
cause of the failure. Please note that even failure and cancellation belong to the completed state.
+---------------------------+
| Completed successfully |
+---------------------------+
+----> isDone() = true |
+--------------------------+ | | isSuccess() = true |
| Uncompleted | | +===========================+
+--------------------------+ | | Completed with failure |
| isDone() = false | | +---------------------------+
| isSuccess() = false |----+----> isDone() = true |
| isCancelled() = false | | | cause() = non-null |
| cause() = null | | +===========================+
+--------------------------+ | | Completed by cancellation |
| +---------------------------+
+----> isDone() = true |
| isCancelled() = true |
+---------------------------+
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(RiakFutureListener<V,T> listener)
Add a listener to this RiakFuture.
|
void |
await()
Waits for this RiakFuture to be completed.
|
void |
await(long timeout,
TimeUnit unit)
Waits for this RiakFuture to be completed, or times out.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
Throwable |
cause()
Return information about the operation and why it failed.
|
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
T |
getQueryInfo()
Returns information related to the operation performed.
|
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
isSuccess()
Determine if the operation was successful.
|
void |
removeListener(RiakFutureListener<V,T> listener)
Remove a listener from this RiakFuture.
|
V get() throws InterruptedException
get in interface Future<V>InterruptedExceptionV get(long timeout, TimeUnit unit) throws InterruptedException
get in interface Future<V>InterruptedExceptionboolean isCancelled()
isCancelled in interface Future<V>void await()
throws InterruptedException
InterruptedExceptionvoid await(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - the amount of time to wait before returning.unit - the unit of time.InterruptedExceptionboolean isSuccess()
Throwable cause()
T getQueryInfo()
Useful in async operations when you want to know what operation this future refers to.
void addListener(RiakFutureListener<V,T> listener)
listener - a FiakFutureListener that will be notified when this RiakFuture completes.void removeListener(RiakFutureListener<V,T> listener)
listener - The listener to remove.Copyright © 2014. All rights reserved.