Package net.spy.memcached.internal
Class BulkGetFuture<T>
- java.lang.Object
-
- net.spy.memcached.compat.SpyObject
-
- net.spy.memcached.internal.AbstractListenableFuture<java.util.Map<java.lang.String,T>,BulkGetCompletionListener>
-
- net.spy.memcached.internal.BulkGetFuture<T>
-
- Type Parameters:
T- types of objects returned from the GET
- All Implemented Interfaces:
java.util.concurrent.Future<java.util.Map<java.lang.String,T>>,BulkFuture<java.util.Map<java.lang.String,T>>,ListenableFuture<java.util.Map<java.lang.String,T>,BulkGetCompletionListener>
public class BulkGetFuture<T> extends AbstractListenableFuture<java.util.Map<java.lang.String,T>,BulkGetCompletionListener> implements BulkFuture<java.util.Map<java.lang.String,T>>
Future for handling results from bulk gets. Not intended for general use.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancancelledprivate java.util.concurrent.CountDownLatchlatchprivate java.util.Collection<Operation>opsprivate java.util.Map<java.lang.String,java.util.concurrent.Future<T>>rvMapprivate OperationStatusstatusprivate booleantimeout
-
Constructor Summary
Constructors Constructor Description BulkGetFuture(java.util.Map<java.lang.String,java.util.concurrent.Future<T>> m, java.util.Collection<Operation> getOps, java.util.concurrent.CountDownLatch l, java.util.concurrent.ExecutorService service)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.Future<java.util.Map<java.lang.String,T>>addListener(BulkGetCompletionListener listener)Add a listener to the future, which will be executed once the operation completes.booleancancel(boolean ign)java.util.Map<java.lang.String,T>get()java.util.Map<java.lang.String,T>get(long to, java.util.concurrent.TimeUnit unit)java.util.Map<java.lang.String,T>getSome(long to, java.util.concurrent.TimeUnit unit)Wait for the operation to complete and return results If operation could not complete within specified timeout, partial result is returned.OperationStatusgetStatus()Gets the status of the operation upon completion.private java.util.Map<java.lang.String,T>internalGet(long to, java.util.concurrent.TimeUnit unit, java.util.Collection<Operation> timedoutOps)refactored code common to both get(long, TimeUnit) and getSome(long, TimeUnit).booleanisCancelled()booleanisDone()booleanisTimeout()java.util.concurrent.Future<java.util.Map<java.lang.String,T>>removeListener(BulkGetCompletionListener listener)Remove a previously added listener from the future.voidsetStatus(OperationStatus s)voidsignalComplete()Signals that this future is complete.-
Methods inherited from class net.spy.memcached.internal.AbstractListenableFuture
addToListeners, executor, notifyListener, notifyListeners, notifyListeners, removeFromListeners
-
-
-
-
Field Detail
-
rvMap
private final java.util.Map<java.lang.String,java.util.concurrent.Future<T>> rvMap
-
ops
private final java.util.Collection<Operation> ops
-
latch
private final java.util.concurrent.CountDownLatch latch
-
status
private OperationStatus status
-
cancelled
private boolean cancelled
-
timeout
private boolean timeout
-
-
Method Detail
-
cancel
public boolean cancel(boolean ign)
- Specified by:
cancelin interfacejava.util.concurrent.Future<T>
-
get
public java.util.Map<java.lang.String,T> get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
getSome
public java.util.Map<java.lang.String,T> getSome(long to, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
Description copied from interface:BulkFutureWait for the operation to complete and return results If operation could not complete within specified timeout, partial result is returned. Otherwise, the behavior is identical toFuture.get(long, TimeUnit)- Specified by:
getSomein interfaceBulkFuture<T>- Returns:
- a partial get bulk result
- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public java.util.Map<java.lang.String,T> get(long to, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
internalGet
private java.util.Map<java.lang.String,T> internalGet(long to, java.util.concurrent.TimeUnit unit, java.util.Collection<Operation> timedoutOps) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
refactored code common to both get(long, TimeUnit) and getSome(long, TimeUnit).- Parameters:
to-unit-timedoutOps-- Returns:
- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
getStatus
public OperationStatus getStatus()
Description copied from interface:BulkFutureGets the status of the operation upon completion.- Specified by:
getStatusin interfaceBulkFuture<T>- Returns:
- the operation status.
-
setStatus
public void setStatus(OperationStatus s)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<T>
-
isTimeout
public boolean isTimeout()
- Specified by:
isTimeoutin interfaceBulkFuture<T>- Returns:
- true if timeout was reached, false otherwise
-
addListener
public java.util.concurrent.Future<java.util.Map<java.lang.String,T>> addListener(BulkGetCompletionListener listener)
Description copied from interface:BulkFutureAdd a listener to the future, which will be executed once the operation completes.- Specified by:
addListenerin interfaceBulkFuture<T>- Specified by:
addListenerin interfaceListenableFuture<java.util.Map<java.lang.String,T>,BulkGetCompletionListener>- Parameters:
listener- the listener which will be executed.- Returns:
- the current future to allow for object-chaining.
-
removeListener
public java.util.concurrent.Future<java.util.Map<java.lang.String,T>> removeListener(BulkGetCompletionListener listener)
Description copied from interface:BulkFutureRemove a previously added listener from the future.- Specified by:
removeListenerin interfaceBulkFuture<T>- Specified by:
removeListenerin interfaceListenableFuture<java.util.Map<java.lang.String,T>,BulkGetCompletionListener>- Parameters:
listener- the previously added listener.- Returns:
- the current future to allow for object-chaining.
-
signalComplete
public void signalComplete()
Signals that this future is complete.
-
-