T
- Type of object returned from this future.public class OperationFuture<T> extends AbstractListenableFuture<T,OperationCompletionListener> implements Future<T>
From an OperationFuture, application code can determine if the status of a given Operation in an asynchronous manner.
If for example we needed to update the keys "user:
Modifier and Type | Field and Description |
---|---|
protected OperationStatus |
status |
Constructor and Description |
---|
OperationFuture(String k,
CountDownLatch l,
AtomicReference<T> oref,
long opTimeout,
ExecutorService service)
Create an OperationFuture for a given async operation.
|
OperationFuture(String k,
CountDownLatch l,
long opTimeout,
ExecutorService service)
Create an OperationFuture for a given async operation.
|
Modifier and Type | Method and Description |
---|---|
OperationFuture<T> |
addListener(OperationCompletionListener listener)
Add a listener to the future, which will be executed once the operation
completes.
|
boolean |
cancel()
Cancel this operation, if possible.
|
boolean |
cancel(boolean ign)
Deprecated.
|
T |
get()
Get the results of the given operation.
|
T |
get(long duration,
TimeUnit units)
Get the results of the given operation.
|
Long |
getCas()
Get the CAS for this operation.
|
String |
getKey()
Get the key for this operation.
|
OperationStatus |
getStatus()
Get the current status of this operation.
|
boolean |
isCancelled()
Whether or not the Operation associated with this OperationFuture has been
canceled.
|
boolean |
isDone()
Whether or not the Operation is done and result can be retrieved with
get().
|
OperationFuture<T> |
removeListener(OperationCompletionListener listener)
Remove a previously added listener from the future.
|
void |
set(T o,
OperationStatus s)
Set the Operation associated with this OperationFuture.
|
void |
setCas(long inCas)
Set the key for this operation.
|
void |
setOperation(Operation to)
Set the Operation associated with this OperationFuture.
|
void |
signalComplete()
Signals that this future is complete.
|
addToListeners, executor, notifyListener, notifyListeners, notifyListeners, removeFromListeners
protected OperationStatus status
public OperationFuture(String k, CountDownLatch l, long opTimeout, ExecutorService service)
k
- the key for the operationl
- the latch to be used counting down the OperationFutureopTimeout
- the timeout within which the operation needs to be donepublic OperationFuture(String k, CountDownLatch l, AtomicReference<T> oref, long opTimeout, ExecutorService service)
k
- the key for the operationl
- the latch to be used counting down the OperationFutureoref
- an AtomicReference associated with the operationopTimeout
- the timeout within which the operation needs to be donepublic boolean cancel(boolean ign)
public boolean cancel()
public T get() throws InterruptedException, ExecutionException
get
in interface Future<T>
InterruptedException
ExecutionException
public T get(long duration, TimeUnit units) throws InterruptedException, TimeoutException, ExecutionException
get
in interface Future<T>
duration
- amount of time to waitunits
- unit of time to waitInterruptedException
TimeoutException
ExecutionException
public String getKey()
public void setCas(long inCas)
inCas
- the CAS valuepublic Long getCas()
UnsupportedOperationException
- If this is for an ASCII protocol
configured client.public OperationStatus getStatus()
public void set(T o, OperationStatus s)
o
- the Operation object itselfs
- the OperationStatus associated with this operationpublic void setOperation(Operation to)
to
- the Operation to set this OperationFuture to be trackingpublic boolean isCancelled()
isCancelled
in interface Future<T>
public boolean isDone()
public OperationFuture<T> addListener(OperationCompletionListener listener)
ListenableFuture
addListener
in interface ListenableFuture<T,OperationCompletionListener>
listener
- the listener which will be executed.public OperationFuture<T> removeListener(OperationCompletionListener listener)
ListenableFuture
removeListener
in interface ListenableFuture<T,OperationCompletionListener>
listener
- the previously added listener.public void signalComplete()
Copyright © 2017. All rights reserved.