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 boolean
cancelled
private java.util.concurrent.CountDownLatch
latch
private java.util.Collection<Operation>
ops
private java.util.Map<java.lang.String,java.util.concurrent.Future<T>>
rvMap
private OperationStatus
status
private boolean
timeout
-
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.boolean
cancel(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.OperationStatus
getStatus()
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).boolean
isCancelled()
boolean
isDone()
boolean
isTimeout()
java.util.concurrent.Future<java.util.Map<java.lang.String,T>>
removeListener(BulkGetCompletionListener listener)
Remove a previously added listener from the future.void
setStatus(OperationStatus s)
void
signalComplete()
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:
cancel
in 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:
get
in interfacejava.util.concurrent.Future<T>
- Throws:
java.lang.InterruptedException
java.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:BulkFuture
Wait 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:
getSome
in interfaceBulkFuture<T>
- Returns:
- a partial get bulk result
- Throws:
java.lang.InterruptedException
java.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:
get
in interfacejava.util.concurrent.Future<T>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.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.InterruptedException
java.util.concurrent.ExecutionException
-
getStatus
public OperationStatus getStatus()
Description copied from interface:BulkFuture
Gets the status of the operation upon completion.- Specified by:
getStatus
in interfaceBulkFuture<T>
- Returns:
- the operation status.
-
setStatus
public void setStatus(OperationStatus s)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<T>
-
isTimeout
public boolean isTimeout()
- Specified by:
isTimeout
in 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:BulkFuture
Add a listener to the future, which will be executed once the operation completes.- Specified by:
addListener
in interfaceBulkFuture<T>
- Specified by:
addListener
in 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:BulkFuture
Remove a previously added listener from the future.- Specified by:
removeListener
in interfaceBulkFuture<T>
- Specified by:
removeListener
in 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.
-
-