Class SingleEntryAsynchronousProcessor<K,V,R>
- java.lang.Object
-
- com.tangosol.util.AsynchronousAgent<T>
-
- com.tangosol.util.processor.AbstractAsynchronousProcessor<K,V,R,R>
-
- com.tangosol.util.processor.SingleEntryAsynchronousProcessor<K,V,R>
-
- Type Parameters:
K- the type of the Map entry keyV- the type of the Map entry valueR- the type of value returned by the EntryProcessor
- All Implemented Interfaces:
FlowControl,InvocableMap.EntryProcessor<K,V,R>,Serializable,Future<R>
public class SingleEntryAsynchronousProcessor<K,V,R> extends AbstractAsynchronousProcessor<K,V,R,R>
AnEntryProcessorwrapper class that allows for an asynchronous invocation of the underlying processor against a single cache entry. When used as aFuture(without extending), this implementation will collect the results of asynchronous invocation, providing theresultsemantics identical to theEntryProcessor.processcontract.More advanced use would require extending this class and overriding
onResult(java.util.Map.Entry<K, R>),onComplete(), andonException(java.lang.Throwable)methods.It's very important that the overriding implementations of these methods must be non-blocking. For example, any use of
NamedCacheAPI is completely disallowed, with the only exception of asynchronous agents with disabled flow control.The underlying entry processor is guaranteed to have been fully executed when
onComplete()is called.Note 1: Neither this class nor its extensions need to be serializable. Only the underlying processor is serialized and sent to corresponding servers for execution.
Note 2: This feature is not available on Coherence*Extend clients.- Since:
- 12.2.1
- Author:
- as 2015.01.26
- See Also:
AsynchronousProcessor, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map.Entry<K,R>m_entryThe result of entry processor invocation.protected Throwablem_eReasonReason for the failed operation.-
Fields inherited from class com.tangosol.util.processor.AbstractAsynchronousProcessor
f_processor
-
Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId
-
-
Constructor Summary
Constructors Constructor Description SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor)Construct a SingleEntryAsynchronousProcessor for a given processor.SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId)Construct a SingleEntryAsynchronousProcessor for a given processor.SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId, Executor executor)Construct a SingleEntryAsynchronousProcessor for a given processor.SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, Executor executor)Construct a SingleEntryAsynchronousProcessor for a given processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonComplete()Called after the processor has been notified about all possible partial results or failures and no more are forthcoming.voidonException(Throwable eReason)Called if any part of the operation failed for any reason.voidonResult(Map.Entry<K,R> entry)Called when there is a partial result of the asynchronous execution.-
Methods inherited from class com.tangosol.util.processor.AbstractAsynchronousProcessor
getProcessor, getUnitOfOrderId, process, processAll
-
Methods inherited from class com.tangosol.util.AsynchronousAgent
bind, cancel, checkBacklog, complete, completeExceptionally, drainBacklog, flush, get, get, getCompletableFuture, getException, getResult, isCancelled, isCompletedExceptionally, isDone
-
-
-
-
Constructor Detail
-
SingleEntryAsynchronousProcessor
public SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor)
Construct a SingleEntryAsynchronousProcessor for a given processor.- Parameters:
processor- the underlyingInvocableMap.EntryProcessor
-
SingleEntryAsynchronousProcessor
public SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, Executor executor)
Construct a SingleEntryAsynchronousProcessor for a given processor.- Parameters:
processor- the underlyingInvocableMap.EntryProcessorexecutor- an optionalExecutorto complete the future on, if not provided theDaemons.commonPool()is used
-
SingleEntryAsynchronousProcessor
public SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId)
Construct a SingleEntryAsynchronousProcessor for a given processor.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoriUnitOrderId- the unit-of-order id for this processor
-
SingleEntryAsynchronousProcessor
public SingleEntryAsynchronousProcessor(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId, Executor executor)
Construct a SingleEntryAsynchronousProcessor for a given processor.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoriUnitOrderId- the unit-of-order id for this processorexecutor- an optionalExecutorto complete the future on, if not provided theDaemons.commonPool()is used
-
-
Method Detail
-
onResult
public void onResult(Map.Entry<K,R> entry)
Description copied from class:AbstractAsynchronousProcessorCalled when there is a partial result of the asynchronous execution.For a given request, calls to this method and
AbstractAsynchronousProcessor.onException(java.lang.Throwable)may come concurrently.For ordering guarantees across different processor invocations see
AbstractAsynchronousProcessor.getUnitOfOrderId().Note: Overriding implementations of this method must be non-blocking.
-
onException
public void onException(Throwable eReason)
Description copied from class:AbstractAsynchronousProcessorCalled 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.
- Specified by:
onExceptionin classAbstractAsynchronousProcessor<K,V,R,R>- Parameters:
eReason- the reason of failure
-
onComplete
public void onComplete()
Description copied from class:AbstractAsynchronousProcessorCalled 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 onCompleteFor ordering guarantees across processors seeAbstractAsynchronousProcessor.getUnitOfOrderId().Note: Overriding implementations of this method must be non-blocking.
- Specified by:
onCompletein classAbstractAsynchronousProcessor<K,V,R,R>
-
-