K - the type of the Map entry keyV - the type of the Map entry valueR - the type of value returned by the EntryProcessorT - the type of the resultpublic abstract class AbstractAsynchronousProcessor<K,V,R,T> extends AsynchronousAgent<T> implements InvocableMap.EntryProcessor<K,V,R>
| Modifier and Type | Field and Description |
|---|---|
protected InvocableMap.EntryProcessor<K,V,R> |
f_processor
The underlying entry processor.
|
m_control, m_fFlowControl, m_iOrderId| Modifier | Constructor and Description |
|---|---|
protected |
AbstractAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, boolean fFlowControl, int iUnitOrderId)
Construct AbstractAsynchronousProcessor instance.
|
| Modifier and Type | Method and Description |
|---|---|
InvocableMap.EntryProcessor<K,V,R> |
getProcessor()
Obtain the underlying entry processor.
|
int |
getUnitOfOrderId()
Return a unit-of-order id associated with this processor.
|
abstract void |
onComplete()
Called after the processor has been notified about all possible partial results or failures and no more are forthcoming.
|
abstract void |
onException(Throwable eReason)
Called if any part of the operation failed for any reason.
|
abstract void |
onResult(Map.Entry<K,R> entry)
Called when there is a partial result of the asynchronous execution.
|
R |
process(InvocableMap.Entry<K,V> entry)
Not supported.
|
Map<K,R> |
processAll(Set<? extends InvocableMap.Entry<K,V>> setEntries)
Not supported.
|
bind, cancel, checkBacklog, complete, completeExceptionally, drainBacklog, flush, get, get, getCompletableFuture, getException, getResult, isAutoFlowControl, isCancelled, isCompletedExceptionally, isDoneprotected final InvocableMap.EntryProcessor<K,V,R> f_processor
protected AbstractAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, boolean fFlowControl, int iUnitOrderId)
processor - the underlying InvocableMap.EntryProcessorfFlowControl - 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 processorpublic abstract void onResult(Map.Entry<K,R> entry)
For a given request, calls to this method and onException(java.lang.Throwable) may come concurrently.
For ordering guarantees across different processor invocations see getUnitOfOrderId().
Note: Overriding implementations of this method must be non-blocking.
entry - an entry holding the key and a result of the operation for the given keypublic abstract void onComplete()
InvocableMap's methods, this method is guaranteed to be called once and only once.
Possible call back sequences are:
cache.invoke
...
onResult
onComplete
cache.invoke
...
onException
onComplete
cache.invokeAll
...
onResult
onException
onException
onResult
onComplete
For ordering guarantees across processors see getUnitOfOrderId().
Note: Overriding implementations of this method must be non-blocking.
public abstract void onException(Throwable eReason)
"complete" the operation.
Note: Overriding implementations of this method must be non-blocking.
eReason - the reason of failurepublic int getUnitOfOrderId()
If two consecutive "invoke" calls are made using AsynchronousProcessors with the same order id and the same key set, then the corresponding execution and calls to onResult(java.util.Map.Entry<K, R>) are going to happen in the exact same order.
If two consecutive "invoke" calls are made using AsynchronousProcessors with the same order id and the same partition set, then the the corresponding execution and calls to onComplete() are going to happen in the exact same order.
Note 1: The ordering guarantee is respected between AsynchronousProcessors and AsynchronousAggregators with the same unit-of-order id.
Note 2: There is no ordering guarantees between asynchronous and synchronous operations.
public InvocableMap.EntryProcessor<K,V,R> getProcessor()
public R process(InvocableMap.Entry<K,V> entry)
process in interface InvocableMap.EntryProcessor<K,V,R>entry - the Entry to process
Note: if this method throws an exception, all modifications to the supplied entry or any other entries retrieved via the BackingMapContext.getBackingMapEntry(java.lang.Object) API will be rolled back leaving all underlying values unchanged.
public Map<K,R> processAll(Set<? extends InvocableMap.Entry<K,V>> setEntries)
processAll in interface InvocableMap.EntryProcessor<K,V,R>setEntries - a Set of InvocableMap.Entry objects to process