R - Result type.public abstract class GridCacheQueryFutureAdapter<K,V,R> extends GridFutureAdapter<Collection<R>> implements GridCacheQueryFuture<R>, GridTimeoutObject
AbstractQueuedSynchronizer.ConditionObject| Modifier and Type | Field and Description |
|---|---|
protected GridCacheContext<K,V> |
cctx
Cache context.
|
protected boolean |
loc |
protected GridLogger |
log
Logger.
|
protected Object |
mux |
protected GridCacheQueryBean |
qry |
ctx| Modifier | Constructor and Description |
|---|---|
protected |
GridCacheQueryFutureAdapter() |
protected |
GridCacheQueryFutureAdapter(GridCacheContext<K,V> cctx,
GridCacheQueryBean qry,
boolean loc) |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns number of elements that are already fetched and can
be returned from
GridCacheQueryFuture.next() method without blocking. |
boolean |
cancel()
Default no-op implementation that always returns
false. |
protected abstract void |
cancelQuery() |
long |
endTime() |
protected void |
enqueue(Collection<?> col) |
Collection<R> |
get()
Synchronously waits for completion of the computation and
returns computation result.
|
Collection<R> |
get(long timeout,
TimeUnit unit)
Synchronously waits for completion of the computation for
up to the timeout specified and returns computation result.
|
protected abstract void |
loadAllPages()
Loads all left pages.
|
protected abstract void |
loadPage()
Loads next page.
|
R |
next()
Returns next element from result set.
|
boolean |
onDone(Collection<R> res,
Throwable err)
Callback to notify that future is finished.
|
protected void |
onNodeLeft(UUID evtNodeId) |
protected abstract boolean |
onPage(UUID nodeId,
boolean last) |
void |
onPage(UUID nodeId,
Collection<?> data,
Throwable err,
boolean finished) |
void |
onTimeout()
Timeout callback.
|
void |
printMemoryStats() |
GridCacheQueryBean |
query() |
GridUuid |
timeoutId() |
String |
toString() |
chain, checkValid, concurrentNotify, concurrentNotify, duration, error, get, get0, isCancelled, isDone, isFailed, isValid, listenAsync, onCancelled, onDone, onDone, onDone, readExternal, result, startTime, stopListenAsync, syncNotify, syncNotify, tryAcquireShared, tryReleaseShared, writeExternalacquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryReleasegetExclusiveOwnerThread, setExclusiveOwnerThreadclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisDonechain, concurrentNotify, concurrentNotify, duration, get, isCancelled, listenAsync, startTime, stopListenAsync, syncNotify, syncNotifyprotected GridCacheContext<K,V> cctx
protected GridLogger log
protected final GridCacheQueryBean qry
protected final Object mux
protected boolean loc
protected GridCacheQueryFutureAdapter()
protected GridCacheQueryFutureAdapter(GridCacheContext<K,V> cctx, GridCacheQueryBean qry, boolean loc)
cctx - Context.qry - Query.loc - Local query or not.public GridCacheQueryBean query()
public boolean onDone(Collection<R> res, Throwable err)
null exception is passed in
the result value will be ignored.onDone in class GridFutureAdapter<Collection<R>>res - Optional result.err - Optional error.True if result was set by this call.public int available()
GridCacheQueryFuture.next() method without blocking.available in interface GridCacheQueryFuture<R>public R next()
This is a blocking call which will wait if there are no elements available immediately.
next in interface GridCacheQueryFuture<R>null if all the elements.protected void onNodeLeft(UUID evtNodeId)
evtNodeId - Removed or failed node Id.protected void enqueue(Collection<?> col)
col - Collection.public void onPage(@Nullable UUID nodeId, @Nullable Collection<?> data, @Nullable Throwable err, boolean finished)
nodeId - Sender node.data - Page data.err - Error (if was).finished - Finished or not.public Collection<R> get() throws GridException
get in interface GridFuture<Collection<R>>get in class GridFutureAdapter<Collection<R>>GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.GridException - If computation failed.public Collection<R> get(long timeout, TimeUnit unit) throws GridException
get in interface GridFuture<Collection<R>>get in class GridFutureAdapter<Collection<R>>timeout - The maximum time to wait.unit - The time unit of the timeout argument.GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.GridFutureTimeoutException - Subclass of GridException thrown if the wait was timed out.GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.GridException - If computation failed.protected abstract boolean onPage(UUID nodeId, boolean last)
nodeId - Sender node id.last - Whether page is last.protected abstract void loadPage()
protected abstract void loadAllPages()
throws GridInterruptedException
GridInterruptedException - If thread is interrupted.public boolean cancel()
throws GridException
false.
Futures that do support cancellation should override this method
and call GridFutureAdapter.onCancelled() callback explicitly if cancellation
indeed did happen.cancel in interface GridCacheQueryFuture<R>cancel in interface GridFuture<Collection<R>>cancel in class GridFutureAdapter<Collection<R>>True if future was canceled (i.e. was not finished prior to this call).GridException - If cancellation failed.protected abstract void cancelQuery()
throws GridException
GridException - In case of error.public GridUuid timeoutId()
timeoutId in interface GridTimeoutObjectpublic long endTime()
endTime in interface GridTimeoutObjectendTime in class GridFutureAdapter<Collection<R>>public void onTimeout()
onTimeout in interface GridTimeoutObjectpublic String toString()
toString in class GridFutureAdapter<Collection<R>>public void printMemoryStats()
Copyright © 2014. All rights reserved.