T
- The core response type.S
- The core query info type.T2
- The converted response type.S2
- The converted query info type.public abstract class CoreFutureAdapter<T2,S2,T,S> extends ListenableFuture<T2,S2> implements RiakFutureListener<T,S>
Constructor and Description |
---|
CoreFutureAdapter(RiakFuture<T,S> coreFuture) |
Modifier and Type | Method and Description |
---|---|
void |
await()
Waits for this RiakFuture to be completed.
|
boolean |
await(long timeout,
TimeUnit unit)
Waits for this RiakFuture to be completed for a set amount of time.
|
boolean |
cancel(boolean mayInterruptIfRunning)
Not supported due to limitations of the Riak API.
|
Throwable |
cause()
Return information about the operation and why it failed.
|
protected abstract S2 |
convertQueryInfo(S coreQueryInfo) |
protected abstract T2 |
convertResponse(T coreResponse) |
T2 |
get()
Waits for this RiakFuture to be completed if necessary and returns the response if available.
|
T2 |
get(long timeout,
TimeUnit unit)
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.
|
T2 |
getNow()
Return the result without blocking or throwing an exception.
|
S2 |
getQueryInfo()
Returns information related to the operation performed.
|
void |
handle(RiakFuture<T,S> f) |
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
isSuccess()
Determine if the operation completed successfully.
|
addListener, notifyListeners, removeListener
public CoreFutureAdapter(RiakFuture<T,S> coreFuture)
public boolean cancel(boolean mayInterruptIfRunning)
RiakFuture
At present time there is no way to cancel an operation sent to Riak. This method will never succeed and always return false.
public T2 get() throws InterruptedException, ExecutionException
RiakFuture
get
in interface RiakFuture<T2,S2>
get
in interface Future<T2>
InterruptedException
- if the current thread was interrupted
while waitingExecutionException
- if the computation threw an
exceptionpublic T2 get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
RiakFuture
Note that the timeout value here is how long you are willing to wait for this RiakFuture to complete. If you wish to set a timeout on the command itself, use the timeout() method provided in the command's associated builder.
get
in interface RiakFuture<T2,S2>
get
in interface Future<T2>
timeout
- the amount of time to wait before returning.unit
- the unit of time.InterruptedException
- if the current thread was interrupted
while waiting.ExecutionException
- if the computation threw an
exception.TimeoutException
- if the wait timed out.public T2 getNow()
RiakFuture
RiakFuture.isDone()
and not rely on the returned null value.getNow
in interface RiakFuture<T2,S2>
RiakFuture.isDone()
,
RiakFuture.isSuccess()
public boolean isCancelled()
isCancelled
in interface RiakFuture<T2,S2>
isCancelled
in interface Future<T2>
public boolean isDone()
public void await() throws InterruptedException
RiakFuture
Upon returning, the operation has completed. Checking isSuccess() tells you if it did so successfully.
await
in interface RiakFuture<T2,S2>
InterruptedException
- if the current thread was interrupted
while waitingRiakFuture.isSuccess()
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
RiakFuture
Note that the timeout value here is how long you are willing to wait for this RiakFuture to complete. Upon return you can check isDone() to see if the future has completed yet or not. The operation is still in progress if that returns false.
If you wish to set a timeout on the command itself, use the timeout() method provided in the command's associated builder.
await
in interface RiakFuture<T2,S2>
timeout
- the amount of time to wait before returning.unit
- the unit of time.true
if the future completed and false
if the waiting time elapsed before it completedInterruptedException
- if the current thread was interrupted
while waitingRiakFuture.isDone()
,
RiakFuture.isSuccess()
public boolean isSuccess()
RiakFuture
isSuccess
in interface RiakFuture<T2,S2>
public Throwable cause()
RiakFuture
Note this will return null if the operation completed successfully.
cause
in interface RiakFuture<T2,S2>
RiakFuture.isSuccess()
public S2 getQueryInfo()
RiakFuture
Useful in async operations when you want to know what operation this future refers to.
getQueryInfo
in interface RiakFuture<T2,S2>
public void handle(RiakFuture<T,S> f)
handle
in interface RiakFutureListener<T,S>
Copyright © 2016. All rights reserved.