Class GridCompoundFuture<T,R>
- java.lang.Object
-
- org.apache.ignite.internal.util.future.GridFutureAdapter<R>
-
- org.apache.ignite.internal.util.future.GridCompoundFuture<T,R>
-
- All Implemented Interfaces:
Serializable,IgniteInternalFuture<R>,IgniteInClosure<IgniteInternalFuture<T>>
- Direct Known Subclasses:
CacheObjectsReleaseFuture,GridCacheCompoundFuture,GridCompoundIdentityFuture,GridDhtForceKeysFuture,GridServiceDeploymentCompoundFuture,InitNewCoordinatorFuture,SchemaIndexCacheCompoundFuture
public class GridCompoundFuture<T,R> extends GridFutureAdapter<R> implements IgniteInClosure<IgniteInternalFuture<T>>
Future composed of multiple inner futures.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridCompoundFuture()Default constructor.GridCompoundFuture(@Nullable IgniteReducer<T,R> rdc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GridCompoundFuture<T,R>add(IgniteInternalFuture<T> fut)Adds a future to this compound future.voidapply(IgniteInternalFuture<T> fut)Closure body.booleancancel()Default no-op implementation that always returnsfalse.protected voidclear()Clear futures.protected ObjectcompoundsLockedExclusively(Supplier<Object> supplier)Locks compounds list and executes code insupplier, when the lock holds.protected voidcompoundsReadLock()Locks compound to read.protected voidcompoundsReadUnlock()Unlocks compound to read.protected IgniteInternalFuture<T>future(int idx)Returns future at the specified position in this list.Collection<IgniteInternalFuture<T>>futures()Gets collection of futures.protected intfuturesCountNoLock()protected booleanhasFutures()protected booleanhasPending()Checks if there are pending futures.protected booleanignoreFailure(Throwable err)Checks if this compound future should ignore this particular exception.booleaninitialized()protected voidlogDebug(IgniteLogger log, String msg)protected voidlogError(IgniteLogger log, String msg, Throwable e)GridCompoundFuture<T,R>markInitialized()Mark this future as initialized.protected booleanprocessFailure(Throwable err, IgniteInternalFuture<T> fut)Processes error thrown by some of the inner futures.StringtoString()-
Methods inherited from class org.apache.ignite.internal.util.future.GridFutureAdapter
chain, chain, chain, chain, chainCompose, chainCompose, error, get, get, get, getUninterruptibly, ignoreInterrupts, isCancelled, isDone, isFailed, listen, listen, logger, onCancelled, onDone, onDone, onDone, onDone, onDone, reset, result
-
-
-
-
Constructor Detail
-
GridCompoundFuture
public GridCompoundFuture()
Default constructor.
-
GridCompoundFuture
public GridCompoundFuture(@Nullable @Nullable IgniteReducer<T,R> rdc)- Parameters:
rdc- Reducer.
-
-
Method Detail
-
apply
public final void apply(IgniteInternalFuture<T> fut)
Closure body.- Specified by:
applyin interfaceIgniteInClosure<T>- Parameters:
fut- Closure argument.
-
cancel
public boolean cancel() throws IgniteCheckedExceptionDefault no-op implementation that always returnsfalse. Futures that do support cancellation should override this method and callGridFutureAdapter.onCancelled()callback explicitly if cancellation indeed did happen.- Specified by:
cancelin interfaceIgniteInternalFuture<T>- Overrides:
cancelin classGridFutureAdapter<R>- Returns:
Trueif future was canceled (i.e. was not finished prior to this call).- Throws:
IgniteCheckedException- If cancellation failed.
-
compoundsReadLock
protected void compoundsReadLock()
Locks compound to read.
-
compoundsReadUnlock
protected void compoundsReadUnlock()
Unlocks compound to read.
-
compoundsLockedExclusively
protected Object compoundsLockedExclusively(Supplier<Object> supplier)
Locks compounds list and executes code insupplier, when the lock holds.- Parameters:
supplier- Closure to execute some code when the compounds are locked exclusively.- Returns:
- A result of the
supplier.
-
futures
public final Collection<IgniteInternalFuture<T>> futures()
Gets collection of futures.- Returns:
- Collection of futures.
-
ignoreFailure
protected boolean ignoreFailure(Throwable err)
Checks if this compound future should ignore this particular exception.- Parameters:
err- Exception to check.- Returns:
Trueif this error should be ignored.
-
processFailure
protected boolean processFailure(Throwable err, IgniteInternalFuture<T> fut)
Processes error thrown by some of the inner futures.- Parameters:
err- Thrown exception.fut- Failed future.- Returns:
Trueif this error should be ignored.
-
hasPending
protected final boolean hasPending()
Checks if there are pending futures. This is not the same asGridFutureAdapter.isDone()because child classes may overrideGridFutureAdapter.onDone(Object, Throwable)call and delay completion.- Returns:
Trueif there are pending futures.
-
add
public final GridCompoundFuture<T,R> add(IgniteInternalFuture<T> fut)
Adds a future to this compound future.- Parameters:
fut- Future to add.
-
clear
protected final void clear()
Clear futures.
-
initialized
public final boolean initialized()
- Returns:
Trueif this future was initialized. Initialization happens whenmarkInitialized()method is called on future.
-
markInitialized
public final GridCompoundFuture<T,R> markInitialized()
Mark this future as initialized.
-
logError
protected void logError(IgniteLogger log, String msg, Throwable e)
- Parameters:
log- IgniteLogger.msg- ShortMessage.e- Exception.
-
logDebug
protected void logDebug(IgniteLogger log, String msg)
- Parameters:
log- IgniteLogger.msg- ShortMessage.
-
future
protected final IgniteInternalFuture<T> future(int idx)
Returns future at the specified position in this list.- Parameters:
idx- - index of the element to return- Returns:
- Future.
-
futuresCountNoLock
protected final int futuresCountNoLock()
- Returns:
- Futures size.
-
hasFutures
protected final boolean hasFutures()
- Returns:
Trueif has at least one future.
-
toString
public String toString()
- Overrides:
toStringin classGridFutureAdapter<R>
-
-