Class AsynchronousAggregator<K,V,P,R>
- Type Parameters:
K
- the type of the Map entry keysV
- the type of the Map entry valuesP
- the type of the intermediate result during the parallel stageR
- the type of the value returned by the StreamingAggregator
- All Implemented Interfaces:
FlowControl
,InvocableMap.EntryAggregator<K,
,V, R> Serializable
,Future<R>
EntryAggregator
wrapper class that allows for
an asynchronous invocation of the underlying aggregator. When used as a
Future
(without extending), this implementation will simply provide
the result
of asynchronous streaming aggregation according
to semantics of the corresponding EntryAggregator.aggregate
contract.
More advanced use would require extending this class and overriding onResult(P)
and onException(java.lang.Throwable)
methods. It's very important that
overriding implementations of these methods must be non-blocking. For example,
any use of NamedCache
API is completely disallowed with the only
exception of AsynchronousAggregators
and
AsynchronousProcessor(InvocableMap.EntryProcessor)
The underlying entry processor is guaranteed to have been fully executed when
either onResult()
or onException()
are called.
Note 1: Neither this class nor its extensions need to be serializable. Only the
underlying aggregator is serialized and sent to corresponding servers for
execution.
Note 2: This feature is not available on Coherence*Extend clients.
- Author:
- gg/mf 2012.12.21
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Fields inherited from class com.tangosol.util.aggregator.AbstractAsynchronousAggregator
m_aggregator
Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId
-
Constructor Summary
ConstructorDescriptionAsynchronousAggregator
(InvocableMap.StreamingAggregator<K, V, P, R> aggregator) Construct an AsynchronousAggregator for a given streaming aggregator.AsynchronousAggregator
(InvocableMap.StreamingAggregator<K, V, P, R> aggregator, int iUnitOrderId) Construct an AsynchronousAggregator for a given streaming aggregator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called after this asynchronous aggregator has been notified about all possible partial results or failures and no more are forthcoming.void
onException
(Throwable eReason) Called if the operation failed for any reason.void
Called when the aggregation result is available.Methods inherited from class com.tangosol.util.aggregator.AbstractAsynchronousAggregator
aggregate, getAggregator, getUnitOfOrderId
Methods inherited from class com.tangosol.util.AsynchronousAgent
bind, cancel, checkBacklog, complete, completeExceptionally, drainBacklog, flush, get, get, getCompletableFuture, getException, getResult, isCancelled, isCompletedExceptionally, isDone
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
Methods inherited from interface com.tangosol.util.InvocableMap.EntryAggregator
aggregate
-
Field Details
-
m_eReason
Reason for the failed operation.
-
-
Constructor Details
-
AsynchronousAggregator
Construct an AsynchronousAggregator for a given streaming aggregator.- Parameters:
aggregator
- the underlying streaming aggregator
-
AsynchronousAggregator
public AsynchronousAggregator(InvocableMap.StreamingAggregator<K, V, P, R> aggregator, int iUnitOrderId) Construct an AsynchronousAggregator for a given streaming aggregator.- Parameters:
aggregator
- the underlying streaming aggregatoriUnitOrderId
- the unit-of-order id for this aggregator
-
-
Method Details
-
onResult
Called when the aggregation result is available.For ordering guarantees see
AbstractAsynchronousAggregator.getUnitOfOrderId()
.Note: Overriding implementations of this method must be non-blocking.
-
onException
Called if the operation failed for any reason.Note: Overriding implementations of this method must be non-blocking.
- Specified by:
onException
in classAbstractAsynchronousAggregator<K,
V, P, R> - Parameters:
eReason
- the reason of failure
-
onComplete
public void onComplete()Description copied from class:AbstractAsynchronousAggregator
Called after this asynchronous aggregator has been notified about all possible partial results or failures and no more are forthcoming.As long as this aggregator was submitted to any of
InvocableMap
's methods, this method is guaranteed to be called once and only once.Possible call back sequences are:
cache.aggregate ... onResult onComplete cache.aggregate ... onException onComplete cache.aggregate ... onResult onException onException onResult onComplete
For ordering guarantees across processors seeAbstractAsynchronousAggregator.getUnitOfOrderId()
.Note:
Overriding implementations of this method must be non-blocking.
If the StreamingAggregator signaled to short-circuit the aggregation while
combining partial results
, onComplete() could be called before all the results are received.- Specified by:
onComplete
in classAbstractAsynchronousAggregator<K,
V, P, R>
-