Class AsynchronousAggregator<K,V,P,R>

java.lang.Object
com.tangosol.util.AsynchronousAgent<R>
com.tangosol.util.aggregator.AbstractAsynchronousAggregator<K,V,P,R>
com.tangosol.util.aggregator.AsynchronousAggregator<K,V,P,R>
Type Parameters:
K - the type of the Map entry keys
V - the type of the Map entry values
P - the type of the intermediate result during the parallel stage
R - the type of the value returned by the StreamingAggregator
All Implemented Interfaces:
FlowControl, InvocableMap.EntryAggregator<K,V,R>, Serializable, Future<R>

public class AsynchronousAggregator<K,V,P,R> extends AbstractAsynchronousAggregator<K,V,P,R> implements InvocableMap.EntryAggregator<K,V,R>
A marker 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:
  • Field Details

    • m_eReason

      protected volatile Throwable m_eReason
      Reason for the failed operation.
  • Constructor Details

    • AsynchronousAggregator

      public AsynchronousAggregator(InvocableMap.StreamingAggregator<K,V,P,R> aggregator)
      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 aggregator
      iUnitOrderId - the unit-of-order id for this aggregator
  • Method Details

    • onResult

      public void onResult(P result)
      Called when the aggregation result is available.

      For ordering guarantees see AbstractAsynchronousAggregator.getUnitOfOrderId().

      Note: Overriding implementations of this method must be non-blocking.

      Specified by:
      onResult in class AbstractAsynchronousAggregator<K,V,P,R>
      Parameters:
      result - the result
    • onException

      public void onException(Throwable eReason)
      Called if the operation failed for any reason.

      Note: Overriding implementations of this method must be non-blocking.

      Specified by:
      onException in class AbstractAsynchronousAggregator<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 see AbstractAsynchronousAggregator.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 class AbstractAsynchronousAggregator<K,V,P,R>