Class StreamingAsynchronousProcessor<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<Void>
EntryProcessor wrapper class that allows for
an asynchronous invocation of the underlying processor. Unlike
AsynchronousProcessor, this implementation does not collect the
results of the underlying entry processor execution, but simply streams
partial results to the provided partial results callback.
This allows for a much lower memory overhead if the complete result set does not to be realized on the client.
It's very important that the overriding implementations of
onComplete(), onResult(java.util.Map.Entry<K, R>) and onException(java.lang.Throwable),
and provided callbacks must be non-blocking. For example, any use of
NamedCache API 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.
- Author:
- as 2015.01.28
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
FieldsModifier and TypeFieldDescriptionThe user-provided callback that will be invoked for each partial result.Fields inherited from class com.tangosol.util.processor.AbstractAsynchronousProcessor
f_processorFields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId -
Constructor Summary
ConstructorsConstructorDescriptionStreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial, Executor executor) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial, Executor executor) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled 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.voidCalled when there is a partial result of the asynchronous execution.Methods inherited from class com.tangosol.util.processor.AbstractAsynchronousProcessor
getProcessor, getUnitOfOrderId, process, processAllMethods inherited from class com.tangosol.util.AsynchronousAgent
bind, cancel, checkBacklog, complete, completeExceptionally, drainBacklog, flush, get, get, getCompletableFuture, getException, getResult, isCancelled, isCompletedExceptionally, isDoneMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
f_onPartial
The user-provided callback that will be invoked for each partial result.
-
-
Constructor Details
-
StreamingAsynchronousProcessor
public StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCacheAPI is completely disallowed.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoronPartial- a user-defined callback that will be called for each partial result
-
StreamingAsynchronousProcessor
public StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial, Executor executor) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCacheAPI is completely disallowed.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoronPartial- a user-defined callback that will be called for each partial resultexecutor- an optionalExecutorto complete the future on, if not provided theDaemons.commonPool()is used
-
StreamingAsynchronousProcessor
public StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCacheAPI is completely disallowed.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoriUnitOrderId- the unit-of-order id for this processoronPartial- a user-defined callback that will be called for each partial result
-
StreamingAsynchronousProcessor
public StreamingAsynchronousProcessor(InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId, Consumer<? super Map.Entry<? extends K, ? extends R>> onPartial, Executor executor) Construct a StreamingAsynchronousProcessor for a given processor and one or more callbacks.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCacheAPI is completely disallowed.- Parameters:
processor- the underlyingInvocableMap.EntryProcessoriUnitOrderId- the unit-of-order id for this processoronPartial- a user-defined callback that will be called for each partial resultexecutor- an optionalExecutorto complete the future on, if not provided theDaemons.commonPool()is used
-
-
Method Details
-
onResult
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
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, Void> - 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, Void>
-