Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.util.aggregator
Class AsynchronousAggregator

java.lang.Object
  extended by com.tangosol.util.AsynchronousAgent
      extended by com.tangosol.util.aggregator.AsynchronousAggregator

All Implemented Interfaces:
FlowControl, InvocableMap.EntryAggregator, java.io.Serializable, java.util.concurrent.Future

public class AsynchronousAggregator
extends AsynchronousAgent
implements InvocableMap.EntryAggregator

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 parallel aggregation according to semantics of the corresponding EntryAggregator.aggregate contract.

More advanced use would require extending this class and overriding onResult(java.lang.Object) 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 AsynchronousProcessors with disabled flow control.

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:
AsynchronousProcessor

Field Summary

 

Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_eReason, m_fFlowControl, m_iOrderId, m_oResult

 

Constructor Summary
AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator)
          Construct an AsynchronousAggregator for a given parallel aggregator and the automatic flow control "on".
AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator, boolean fFlowControl)
          Construct an AsynchronousAggregator for a given parallel aggregator.
AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator, boolean fFlowControl, int iUnitOrderId)
          Construct an AsynchronousAggregator for a given parallel aggregator.

 

Method Summary
 java.lang.Object aggregate(java.util.Set setEntries)
          Not supported.
 InvocableMap.ParallelAwareAggregator getAggregator()
          Return the underlying parallel aggregator.
 int getUnitOfOrderId()
          Return a unit-of-order id associated with this aggregator.
 void onException(java.lang.Throwable eReason)
          Called if the operation failed for any reason.
 void onResult(java.lang.Object oResult)
          Called when the aggregation result is available.

 

Methods inherited from class com.tangosol.util.AsynchronousAgent
bind, cancel, checkBacklog, drainBacklog, flush, get, get, isAutoFlowControl, isCancelled, isDone, setException, setResult, toString

 

Constructor Detail

AsynchronousAggregator

public AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator)
Construct an AsynchronousAggregator for a given parallel aggregator and the automatic flow control "on".
Parameters:
aggregator - the underlying parallel aggregator

AsynchronousAggregator

public AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator,
                              boolean fFlowControl)
Construct an AsynchronousAggregator for a given parallel aggregator.
Parameters:
aggregator - the underlying parallel aggregator
fFlowControl - if true, the calling thread could be held by the service flow control logic (based on the destination backlog); otherwise it's the caller's responsibility to modulate the request flow (e.g. ensure that the invocation rate does not outpace the response rate)

AsynchronousAggregator

public AsynchronousAggregator(InvocableMap.ParallelAwareAggregator aggregator,
                              boolean fFlowControl,
                              int iUnitOrderId)
Construct an AsynchronousAggregator for a given parallel aggregator.
Parameters:
aggregator - the underlying parallel aggregator
fFlowControl - if true, the calling thread could be held by the service flow control logic (based on the destination backlog); otherwise it's the caller's responsibility to modulate the request flow (e.g. ensure that the invocation rate does not outpace the response rate)
iUnitOrderId - the unit-of-order id for this aggregator

Method Detail

onResult

public void onResult(java.lang.Object oResult)
Called when the aggregation result is available.

For ordering guarantees see getUnitOfOrderId().

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

Parameters:
oResult - the result

onException

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

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 corresponding execution and calls to onResult(java.lang.Object) are going to happen in the exact same order.

Note 1: the ordering guarantee is respected between AsynchronousAggregators and AsynchronousProcessors with the same unit-of-order id;
Note 2: there is no ordering guarantee between asynchronous and synchronous operations.

Returns:
the order id

getAggregator

public InvocableMap.ParallelAwareAggregator getAggregator()
Return the underlying parallel aggregator.
Returns:
the underlying aggregator

aggregate

public java.lang.Object aggregate(java.util.Set setEntries)
Not supported.
Specified by:
aggregate in interface InvocableMap.EntryAggregator
Parameters:
setEntries - a Set of read-only InvocableMap.Entry objects to aggregate
Returns:
the aggregated result from processing the entries

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.