Class GridClientFutureAdapter<R>
- java.lang.Object
-
- java.util.concurrent.locks.AbstractOwnableSynchronizer
-
- java.util.concurrent.locks.AbstractQueuedSynchronizer
-
- org.apache.ignite.internal.client.impl.GridClientFutureAdapter<R>
-
- All Implemented Interfaces:
Serializable,GridClientFuture<R>
public class GridClientFutureAdapter<R> extends AbstractQueuedSynchronizer implements GridClientFuture<R>
Future adapter.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
-
-
Constructor Summary
Constructors Constructor Description GridClientFutureAdapter()Creates not-finished future without any result.GridClientFutureAdapter(Throwable err)Creates failed finished future with given error.GridClientFutureAdapter(R res)Creates succeeded finished future with given result.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> GridClientFutureAdapter<T>chain(GridClientFutureCallback<R,T> cb)Creates future's chain and completes chained future, when this future finishes.Rget()Synchronously waits for completion and returns result.Rget(long timeout, TimeUnit unit)Synchronously waits for completion and returns result.booleanisDone()Checks if future is done.voidlisten(GridClientFutureListener<R>... lsnrs)Register new listeners for notification when future completes.voidonDone(Throwable err)Callback to notify that future is finished with error.voidonDone(R res)Callback to notify that future is finished successfully.protected inttryAcquireShared(int ignore)protected booleantryReleaseShared(int ignore)-
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
-
Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer
getExclusiveOwnerThread, setExclusiveOwnerThread
-
-
-
-
Constructor Detail
-
GridClientFutureAdapter
public GridClientFutureAdapter()
Creates not-finished future without any result.
-
GridClientFutureAdapter
public GridClientFutureAdapter(R res)
Creates succeeded finished future with given result.- Parameters:
res- Future result.
-
GridClientFutureAdapter
public GridClientFutureAdapter(Throwable err)
Creates failed finished future with given error.- Parameters:
err- Future error.
-
-
Method Detail
-
get
public R get() throws GridClientException
Synchronously waits for completion and returns result.- Specified by:
getin interfaceGridClientFuture<R>- Returns:
- Completed future result.
- Throws:
GridClientException- In case of error.
-
get
public R get(long timeout, TimeUnit unit) throws GridClientException
Synchronously waits for completion and returns result.- Specified by:
getin interfaceGridClientFuture<R>- Parameters:
timeout- Timeout interval to wait future completes.unit- Timeout interval unit to wait future completes.- Returns:
- Completed future result.
- Throws:
GridClientException- In case of error.GridClientFutureTimeoutException- If timed out before future finishes.
-
isDone
public boolean isDone()
Checks if future is done.- Specified by:
isDonein interfaceGridClientFuture<R>- Returns:
- Whether future is done.
-
onDone
public void onDone(@Nullable R res)Callback to notify that future is finished successfully.- Parameters:
res- Result (can benull).
-
onDone
public void onDone(Throwable err)
Callback to notify that future is finished with error.- Parameters:
err- Error (can't benull).
-
tryAcquireShared
protected final int tryAcquireShared(int ignore)
- Overrides:
tryAcquireSharedin classAbstractQueuedSynchronizer
-
tryReleaseShared
protected final boolean tryReleaseShared(int ignore)
- Overrides:
tryReleaseSharedin classAbstractQueuedSynchronizer
-
listen
public void listen(GridClientFutureListener<R>... lsnrs)
Register new listeners for notification when future completes. Note that current implementations are calling listeners in the completing thread.- Specified by:
listenin interfaceGridClientFuture<R>- Parameters:
lsnrs- Listeners to be registered.
-
chain
public <T> GridClientFutureAdapter<T> chain(GridClientFutureCallback<R,T> cb)
Creates future's chain and completes chained future, when this future finishes.- Type Parameters:
T- New future format to convert this finished future to.- Parameters:
cb- Future callback to convert this future result into expected format.- Returns:
- Chained future with new format.
-
-