Package net.spy.memcached.internal
Class BulkGetFuture<T>
java.lang.Object
net.spy.memcached.compat.SpyObject
net.spy.memcached.internal.AbstractListenableFuture<Map<String,T>,BulkGetCompletionListener>
net.spy.memcached.internal.BulkGetFuture<T>
- Type Parameters:
T
- types of objects returned from the GET
- All Implemented Interfaces:
Future<Map<String,
,T>> BulkFuture<Map<String,
,T>> ListenableFuture<Map<String,
T>, BulkGetCompletionListener>
public class BulkGetFuture<T>
extends AbstractListenableFuture<Map<String,T>,BulkGetCompletionListener>
implements BulkFuture<Map<String,T>>
Future for handling results from bulk gets.
Not intended for general use.
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final CountDownLatch
private final Collection
<Operation> private OperationStatus
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionBulkGetFuture
(Map<String, Future<T>> m, Collection<Operation> getOps, CountDownLatch l, ExecutorService service) -
Method Summary
Modifier and TypeMethodDescriptionaddListener
(BulkGetCompletionListener listener) Add a listener to the future, which will be executed once the operation completes.boolean
cancel
(boolean ign) get()
Wait for the operation to complete and return results If operation could not complete within specified timeout, partial result is returned.Gets the status of the operation upon completion.internalGet
(long to, TimeUnit unit, Collection<Operation> timedoutOps) refactored code common to both get(long, TimeUnit) and getSome(long, TimeUnit).boolean
boolean
isDone()
boolean
removeListener
(BulkGetCompletionListener listener) Remove a previously added listener from the future.void
void
Signals that this future is complete.Methods inherited from class net.spy.memcached.internal.AbstractListenableFuture
addToListeners, executor, notifyListener, notifyListeners, notifyListeners, removeFromListeners
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
rvMap
-
ops
-
latch
-
status
-
cancelled
private boolean cancelled -
timeout
private boolean timeout
-
-
Constructor Details
-
BulkGetFuture
public BulkGetFuture(Map<String, Future<T>> m, Collection<Operation> getOps, CountDownLatch l, ExecutorService service)
-
-
Method Details
-
cancel
public boolean cancel(boolean ign) -
get
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
-
getSome
public Map<String,T> getSome(long to, TimeUnit unit) throws InterruptedException, 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>
- Parameters:
to
-unit
-- Returns:
- a partial get bulk result
- Throws:
InterruptedException
ExecutionException
-
get
public Map<String,T> get(long to, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
internalGet
private Map<String,T> internalGet(long to, TimeUnit unit, Collection<Operation> timedoutOps) throws InterruptedException, ExecutionException refactored code common to both get(long, TimeUnit) and getSome(long, TimeUnit).- Parameters:
to
-unit
-timedoutOps
-- Returns:
- Throws:
InterruptedException
ExecutionException
-
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
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<T>
-
isDone
public boolean isDone() -
isTimeout
public boolean isTimeout()- Specified by:
isTimeout
in interfaceBulkFuture<T>
- Returns:
- true if timeout was reached, false otherwise
-
addListener
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<Map<String,
T>, BulkGetCompletionListener> - Parameters:
listener
- the listener which will be executed.- Returns:
- the current future to allow for object-chaining.
-
removeListener
Description copied from interface:BulkFuture
Remove a previously added listener from the future.- Specified by:
removeListener
in interfaceBulkFuture<T>
- Specified by:
removeListener
in interfaceListenableFuture<Map<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.
-