Class AbstractAsynchronousAggregator<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>
- Direct Known Subclasses:
AsynchronousAggregator
- Author:
- gg/bb 2015.04.02
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Modifier and TypeFieldDescriptionprotected InvocableMap.StreamingAggregator
<K, V, P, R> The underlying aggregator.Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAsynchronousAggregator
(InvocableMap.StreamingAggregator<K, V, P, R> aggregator, int iUnitOrderId) Construct an AsynchronousAggregator for a given streaming aggregator. -
Method Summary
Modifier and TypeMethodDescriptionaggregate
(Set<? extends InvocableMap.Entry<? extends K, ? extends V>> setEntries) Not supported.Return the underlying streaming aggregator.int
Return a unit-of-order id associated with this aggregator.abstract void
Called after this asynchronous aggregator has been notified about all possible partial results or failures and no more are forthcoming.abstract void
onException
(Throwable eReason) Called if the operation failed for any reason.abstract void
Called when there is a partial result of the asynchronous execution.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
-
Field Details
-
m_aggregator
The underlying aggregator.
-
-
Constructor Details
-
AbstractAsynchronousAggregator
protected AbstractAsynchronousAggregator(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 there is a partial result of the asynchronous execution.For a given request, calls to this method and
onException(java.lang.Throwable)
may come concurrently.For ordering guarantees across different aggregator invocations see
getUnitOfOrderId()
.Note: Overriding implementations of this method must be non-blocking.
- Parameters:
result
- the partial result holder
-
onComplete
public abstract void onComplete()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 seegetUnitOfOrderId()
.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. -
onException
Called if the operation failed for any reason.For a given request, calls to this method and
onResult(P)
may come concurrently.Note: Overriding implementations of this method must be non-blocking.
- Parameters:
eReason
- the reason of failure
-
getUnitOfOrderId
public int getUnitOfOrderId()Return a unit-of-order id associated with this aggregator. By default, the unit-of-order id is assigned to the calling thread's hashCode.If two consecutive "aggregate" calls made using
AsynchronousAggregators
with the same order id and involve the same key set, then the correspondingexecution
and calls toonResult(P)
are going to happen in the exact same order.Note 1: the ordering guarantee is respected between
AbstractAsynchronousAggregator
s andAsynchronousProcessor
s with the same unit-of-order id;
Note 2: there is no ordering guarantee between asynchronous and synchronous operations.- Overrides:
getUnitOfOrderId
in classAsynchronousAgent<R>
- Returns:
- the order id
- See Also:
-
getAggregator
Return the underlying streaming aggregator.- Returns:
- the underlying aggregator
-
aggregate
Not supported.- Specified by:
aggregate
in interfaceInvocableMap.EntryAggregator<K,
V, P> - Parameters:
setEntries
- a Set of read-only InvocableMap.Entry objects to aggregate- Returns:
- the aggregated result from processing the entries
-