Class AbstractAsynchronousProcessor<K,V,R,T>
- Type Parameters:
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 result
- All Implemented Interfaces:
FlowControl
,InvocableMap.EntryProcessor<K,
,V, R> Serializable
,Future<T>
- Direct Known Subclasses:
AsynchronousProcessor
,SingleEntryAsynchronousProcessor
,StreamingAsynchronousProcessor
- Since:
- 12.2.1
- Author:
- as 2015.01.26
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Modifier and TypeFieldDescriptionprotected final InvocableMap.EntryProcessor
<K, V, R> The underlying entry processor.Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAsynchronousProcessor
(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId) Construct AbstractAsynchronousProcessor instance. -
Method Summary
Modifier and TypeMethodDescriptionObtain the underlying entry processor.int
Return a unit-of-order id associated with this processor.abstract void
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
Called when there is a partial result of the asynchronous execution.process
(InvocableMap.Entry<K, V> entry) Not supported.processAll
(Set<? extends InvocableMap.Entry<K, V>> setEntries) Not supported.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
-
f_processor
The underlying entry processor.
-
-
Constructor Details
-
AbstractAsynchronousProcessor
protected AbstractAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId) Construct AbstractAsynchronousProcessor instance.- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processor
-
-
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 processor invocations see
getUnitOfOrderId()
.Note: Overriding implementations of this method must be non-blocking.
- Parameters:
entry
- an entry holding the key and a result of the operation for the given key
-
onComplete
public abstract void onComplete()Called after the processor has been notified about all possible partial results or failures and no more are forthcoming. As long as this processor was submitted to any ofInvocableMap
'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 seegetUnitOfOrderId()
.Note: Overriding implementations of this method must be non-blocking.
-
onException
Called if any part of the operation failed for any reason. For operations that span multiple partitions this method could be called more than once. However, unless subclasses override this method, any failure will"complete"
the operation.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 processor. By default, the unit-of-order id is assigned to the calling thread's hashCode.If two consecutive "invoke" calls are made using
AsynchronousProcessors
with the same order id and the same key set, then the correspondingexecution
and calls toonResult(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 correspondingexecution
and calls toonComplete()
are going to happen in the exact same order.Note 1: The ordering guarantee is respected between
AsynchronousProcessors
andAsynchronousAggregator
s with the same unit-of-order id.
Note 2: There is no ordering guarantees between asynchronous and synchronous operations.- Overrides:
getUnitOfOrderId
in classAsynchronousAgent<T>
- Returns:
- the unit-of-order id associated with this processor
- See Also:
-
getProcessor
Obtain the underlying entry processor.- Returns:
- the underlying entry processor
-
process
Not supported.- Specified by:
process
in interfaceInvocableMap.EntryProcessor<K,
V, R> - Parameters:
entry
- the Entry to process- Returns:
- the result of the processing, if any
-
processAll
Not supported.- Specified by:
processAll
in interfaceInvocableMap.EntryProcessor<K,
V, R> - Parameters:
setEntries
- a Set of InvocableMap.Entry objects to process- Returns:
- a Map containing the results of the processing, up to one entry for each InvocableMap.Entry that was processed, keyed by the keys of the Map that were processed, with a corresponding value being the result of the processing for each key
-