Class GridFutureAdapter<R>
- java.lang.Object
-
- org.apache.ignite.internal.util.future.GridFutureAdapter<R>
-
- All Implemented Interfaces:
IgniteInternalFuture<R>
- Direct Known Subclasses:
AbstractCreateSnapshotFutureTask,CacheDistributedGetFutureAdapter.AbstractMiniFuture,ComputeTaskInternalFuture,ConnectFuture,ConnectionRequestFuture,CountDownFuture,FutureTask,GridCacheFutureAdapter,GridCacheMultiTxFuture,GridCacheQueryFutureAdapter,GridCacheQueryManager.QueryResult,GridCompoundFuture,GridCompoundReadRepairFuture,GridDhtAssignmentFetchFuture,GridDhtGetSingleFuture,GridDhtPartitionDemander.RebalanceFuture,GridDhtTopologyFutureAdapter,GridEmbeddedFuture,GridEncryptionManager.KeyChangeFuture,GridNearOptimisticTxPrepareFutureAdapter.KeyLockFuture,GridNearReadRepairAbstractFuture,GridNearTxFastFinishFuture,GridNioFutureImpl,GridServiceDeploymentFuture,GridWorkerFuture,IgniteSnapshotManager.ClusterSnapshotFuture,QueryRunningFuture,SchemaIndexCacheFuture,SchemaOperationClientFuture,SnapshotFinishedFutureTask,SnapshotResponseRemoteFutureTask,StopCachesOnClientReconnectExchangeTask,TcpCommunicationConnectionCheckFuture
public class GridFutureAdapter<R> extends Object implements IgniteInternalFuture<R>
Future adapter.
-
-
Constructor Summary
Constructors Constructor Description GridFutureAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel()Default no-op implementation that always returnsfalse.<T> IgniteInternalFuture<T>chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb)Make a chained future to convert result of this future (when complete) into a new format.<T> IgniteInternalFuture<T>chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb, Executor exec)Make a chained future to convert result of this future (when complete) into a new format.<T> IgniteInternalFuture<T>chain(IgniteOutClosure<T> doneCb)Make a chained future to convert result of this future (when complete) into a new format.<T> IgniteInternalFuture<T>chain(IgniteOutClosure<T> doneCb, Executor exec)Make a chained future to convert result of this future (when complete) into a new format.<T> IgniteInternalFuture<T>chainCompose(IgniteClosure<? super IgniteInternalFuture<R>,IgniteInternalFuture<T>> doneCb)Make a chained future that is completed whendoneCbis executed.<T> IgniteInternalFuture<T>chainCompose(IgniteClosure<? super IgniteInternalFuture<R>,IgniteInternalFuture<T>> doneCb, @Nullable Executor exec)Make a chained future that is completed whendoneCbis executed.Throwableerror()Rget()Synchronously waits for completion of the computation and returns computation result.Rget(long timeout)Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.Rget(long timeout, TimeUnit unit)Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.RgetUninterruptibly()Synchronously waits for completion of the computation and returns computation result ignoring interrupts.voidignoreInterrupts()Determines whether the future will ignore interrupts while waiting for result inget()methods.booleanisCancelled()Returnstrueif this computation was cancelled before it completed normally.booleanisDone()Checks if computation is done.booleanisFailed()voidlisten(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr)Registers listener closure to be asynchronously notified whenever future completes.voidlisten(IgniteRunnable lsnr)Registers listener closure to be asynchronously notified whenever future completes.@Nullable IgniteLoggerlogger()booleanonCancelled()Callback to notify that future is cancelled.booleanonDone()Callback to notify that future is finished withnullresult.booleanonDone(@Nullable Throwable err)Callback to notify that future is finished.booleanonDone(R res)Callback to notify that future is finished.booleanonDone(R res, @Nullable Throwable err)Callback to notify that future is finished.protected booleanonDone(R res, @Nullable Throwable err, boolean cancel)voidreset()Resets future for subsequent reuse.Rresult()StringtoString()
-
-
-
Method Detail
-
ignoreInterrupts
public void ignoreInterrupts()
Determines whether the future will ignore interrupts while waiting for result inget()methods. This call should happen before subsequentget()in order to have guaranteed effect.
-
error
public Throwable error()
- Specified by:
errorin interfaceIgniteInternalFuture<R>- Returns:
- Error value if future has already been completed with error.
-
result
public R result()
- Specified by:
resultin interfaceIgniteInternalFuture<R>- Returns:
- Result value if future has already been completed normally.
-
get
public R get() throws IgniteCheckedException
Synchronously waits for completion of the computation and returns computation result.- Specified by:
getin interfaceIgniteInternalFuture<R>- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
getUninterruptibly
public R getUninterruptibly() throws IgniteCheckedException
Synchronously waits for completion of the computation and returns computation result ignoring interrupts.- Specified by:
getUninterruptiblyin interfaceIgniteInternalFuture<R>- Returns:
- Computation result.
- Throws:
IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
get
public R get(long timeout) throws IgniteCheckedException
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result. This method is equivalent to callingget(long, TimeUnit.MILLISECONDS).- Specified by:
getin interfaceIgniteInternalFuture<R>- Parameters:
timeout- The maximum time to wait in milliseconds.- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureTimeoutCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was timed out.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
get
public R get(long timeout, TimeUnit unit) throws IgniteCheckedException
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.- Specified by:
getin interfaceIgniteInternalFuture<R>- Parameters:
timeout- The maximum time to wait.unit- The time unit of thetimeoutargument.- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureTimeoutCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was timed out.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
listen
public void listen(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr)
Registers listener closure to be asynchronously notified whenever future completes.- Specified by:
listenin interfaceIgniteInternalFuture<R>- Parameters:
lsnr- Listener closure to register.
-
listen
public void listen(IgniteRunnable lsnr)
Registers listener closure to be asynchronously notified whenever future completes.- Specified by:
listenin interfaceIgniteInternalFuture<R>- Parameters:
lsnr- Listener closure to register.
-
chain
public <T> IgniteInternalFuture<T> chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<R>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <T> IgniteInternalFuture<T> chain(IgniteOutClosure<T> doneCb)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<R>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <T> IgniteInternalFuture<T> chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb, Executor exec)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<R>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.exec- Executor to run callback.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <T> IgniteInternalFuture<T> chain(IgniteOutClosure<T> doneCb, Executor exec)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<R>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.exec- Executor to run callback.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chainCompose
public <T> IgniteInternalFuture<T> chainCompose(IgniteClosure<? super IgniteInternalFuture<R>,IgniteInternalFuture<T>> doneCb)
Make a chained future that is completed whendoneCbis executed. Callback is called with this future as the argument, when this future completes. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainComposein interfaceIgniteInternalFuture<R>- Type Parameters:
T- Type parameter.- Parameters:
doneCb- Done callback.- Returns:
- Chained future.
-
chainCompose
public <T> IgniteInternalFuture<T> chainCompose(IgniteClosure<? super IgniteInternalFuture<R>,IgniteInternalFuture<T>> doneCb, @Nullable @Nullable Executor exec)
Make a chained future that is completed whendoneCbis executed. Callback is called with this future as the argument, when this future completes. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainComposein interfaceIgniteInternalFuture<R>- Type Parameters:
T- Type parameter.- Parameters:
doneCb- Done callback.exec- Executor to run callback.- Returns:
- Chained future.
-
logger
@Nullable public @Nullable IgniteLogger logger()
- Returns:
- Logger instance.
-
cancel
public boolean cancel() throws IgniteCheckedExceptionDefault no-op implementation that always returnsfalse. Futures that do support cancellation should override this method and callonCancelled()callback explicitly if cancellation indeed did happen.- Specified by:
cancelin interfaceIgniteInternalFuture<R>- Returns:
Trueif future was canceled (i.e. was not finished prior to this call).- Throws:
IgniteCheckedException- If cancellation failed.
-
isDone
public boolean isDone()
Checks if computation is done.- Specified by:
isDonein interfaceIgniteInternalFuture<R>- Returns:
Trueif computation is done,falseotherwise.
-
isFailed
public boolean isFailed()
- Returns:
Trueif future is completed with exception.
-
isCancelled
public boolean isCancelled()
Returnstrueif this computation was cancelled before it completed normally.- Specified by:
isCancelledin interfaceIgniteInternalFuture<R>- Returns:
Trueif this computation was cancelled before it completed normally.
-
onDone
public final boolean onDone()
Callback to notify that future is finished withnullresult. This method must delegate toonDone(Object, Throwable)method.- Returns:
Trueif result was set by this call.
-
onDone
public final boolean onDone(@Nullable R res)Callback to notify that future is finished. This method must delegate toonDone(Object, Throwable)method.- Parameters:
res- Result.- Returns:
Trueif result was set by this call.
-
onDone
public final boolean onDone(@Nullable @Nullable Throwable err)Callback to notify that future is finished. This method must delegate toonDone(Object, Throwable)method.- Parameters:
err- Error.- Returns:
Trueif result was set by this call.
-
onDone
public boolean onDone(@Nullable R res, @Nullable @Nullable Throwable err)Callback to notify that future is finished. Note that if non-nullexception is passed in the result value will be ignored.- Parameters:
res- Optional result.err- Optional error.- Returns:
Trueif result was set by this call.
-
onDone
protected boolean onDone(@Nullable R res, @Nullable @Nullable Throwable err, boolean cancel)- Parameters:
res- Result.err- Error.cancel-Trueif future is being cancelled.- Returns:
Trueif result was set by this call.
-
reset
public void reset()
Resets future for subsequent reuse.
-
onCancelled
public boolean onCancelled()
Callback to notify that future is cancelled.- Returns:
Trueif cancel flag was set by this call.
-
-