Class AbstractAsynchronousAggregator<K,​V,​P,​R>

    • Constructor Detail

      • 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 aggregator
        iUnitOrderId - the unit-of-order id for this aggregator
      • AbstractAsynchronousAggregator

        protected AbstractAsynchronousAggregator​(InvocableMap.StreamingAggregator<K,​V,​P,​R> aggregator,
                                                 int iUnitOrderId,
                                                 Executor executor)
        Construct an AsynchronousAggregator for a given streaming aggregator.
        Parameters:
        aggregator - the underlying streaming aggregator
        iUnitOrderId - the unit-of-order id for this aggregator
        executor - an optional Executor to complete the future on, if not provided the Daemons.commonPool() is used
    • Method Detail

      • onResult

        public abstract void onResult​(P result)
        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 see 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.

      • onException

        public abstract void onException​(Throwable eReason)
        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
      • aggregate

        public R aggregate​(Set<? extends InvocableMap.Entry<? extends K,​? extends V>> setEntries)
        Not supported.
        Specified by:
        aggregate in interface InvocableMap.EntryAggregator<K,​V,​P>
        Parameters:
        setEntries - a Set of read-only InvocableMap.Entry objects to aggregate
        Returns:
        the aggregated result from processing the entries