Class ContinuousQueryCache.ConverterAsynchronousProcessor
- All Implemented Interfaces:
FlowControl
,InvocableMap.EntryProcessor
,Serializable
,Future
- Enclosing class:
ContinuousQueryCache<K,
V_BACK, V_FRONT>
AsynchronousProcessor
to ensure the result of the EntryProcessor
execution is deserialized prior to passing to the provided AsynchronousProcessor.- Since:
- 12.2.1.4
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Converter
Converter to deserializeBinary
values.protected final AsynchronousProcessor
The delegateAsynchronousProcessor
.Fields inherited from class com.tangosol.util.processor.AsynchronousProcessor
m_eReason, m_listResultEntries
Fields inherited from class com.tangosol.util.AsynchronousAgent
m_control, m_iOrderId
-
Constructor Summary
ConstructorDescriptionConstruct the processor to wrap the providedAsynchronousProcessor
in order to ensure results are properly converted prior to return. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(FlowControl control) Bind this agent with the specified underlying FlowControl object.boolean
cancel
(boolean mayInterruptIfRunning) boolean
checkBacklog
(Continuation continueNormal) Check for an excessive backlog and if the underlying communication channel is indeed clogged, call the specified continuation when the backlog is back to normal or the service terminates.long
drainBacklog
(long cMillis) Check for an excessive backlog and allow blocking the calling thread for up to the specified amount of time.void
flush()
Ensure that any buffered asynchronous operations are dispatched to the underlying tier.get()
Get the CompletableFuture.Helper method that returns an exception (if completed exceptionally).Obtain the underlying entry processor.Helper method that callsAsynchronousAgent.get()
and re-throws checked exceptions as a RuntimeException.int
Return a unit-of-order id associated with this processor.boolean
boolean
Helper method to check if the operation failed.boolean
isDone()
void
Called after the processor has been notified about all possible partial results or failures and no more are forthcoming.void
onException
(Throwable eReason) Called if any part of the operation failed for any reason.void
Called when there is a partial result of the asynchronous execution.process
(InvocableMap.Entry entry) Not supported.processAll
(Set setEntries) Not supported.Methods inherited from class com.tangosol.util.AsynchronousAgent
complete, completeExceptionally
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 delegateAsynchronousProcessor
. -
f_convUp
Converter to deserializeBinary
values.
-
-
Constructor Details
-
ConverterAsynchronousProcessor
Construct the processor to wrap the providedAsynchronousProcessor
in order to ensure results are properly converted prior to return.- Parameters:
processor
- the processor to wrap
-
-
Method Details
-
onResult
Description copied from class:AbstractAsynchronousProcessor
Called 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.
- Overrides:
onResult
in classAsynchronousProcessor
- Parameters:
entry
- an entry holding the key and a result of the operation for the given key
-
onException
Description copied from class:AbstractAsynchronousProcessor
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.
- Overrides:
onException
in classAsynchronousProcessor
- Parameters:
eReason
- the reason of failure
-
onComplete
public void onComplete()Description copied from class:AbstractAsynchronousProcessor
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 seeAbstractAsynchronousProcessor.getUnitOfOrderId()
.Note: Overriding implementations of this method must be non-blocking.
- Overrides:
onComplete
in classAsynchronousProcessor
-
getUnitOfOrderId
public int getUnitOfOrderId()Description copied from class:AbstractAsynchronousProcessor
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 toAbstractAsynchronousProcessor.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 correspondingexecution
and calls toAbstractAsynchronousProcessor.onComplete()
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 classAbstractAsynchronousProcessor
- Returns:
- the unit-of-order id associated with this processor
- See Also:
-
getProcessor
Description copied from class:AbstractAsynchronousProcessor
Obtain the underlying entry processor.- Overrides:
getProcessor
in classAbstractAsynchronousProcessor
- Returns:
- the underlying entry processor
-
process
Description copied from class:AbstractAsynchronousProcessor
Not supported.- Specified by:
process
in interfaceInvocableMap.EntryProcessor
- Overrides:
process
in classAbstractAsynchronousProcessor
- Parameters:
entry
- the Entry to process- Returns:
- the result of the processing, if any
-
processAll
Description copied from class:AbstractAsynchronousProcessor
Not supported.- Specified by:
processAll
in interfaceInvocableMap.EntryProcessor
- Overrides:
processAll
in classAbstractAsynchronousProcessor
- 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
-
bind
Description copied from class:AsynchronousAgent
Bind this agent with the specified underlying FlowControl object. This method is to be used only internally by the service.- Overrides:
bind
in classAsynchronousAgent
- Parameters:
control
- the underlying FlowControl
-
flush
public void flush()Description copied from interface:FlowControl
Ensure that any buffered asynchronous operations are dispatched to the underlying tier.Note: this is a non-blocking call.
- Specified by:
flush
in interfaceFlowControl
- Overrides:
flush
in classAsynchronousAgent
-
checkBacklog
Description copied from interface:FlowControl
Check for an excessive backlog and if the underlying communication channel is indeed clogged, call the specified continuation when the backlog is back to normal or the service terminates. It's important to remember that:- The continuation could be called on any thread; concurrently with the calling thread or on the calling thread itself.
- The continuation is called if and only if this method returns
true
. - The continuation must not make any blocking calls.
- Specified by:
checkBacklog
in interfaceFlowControl
- Overrides:
checkBacklog
in classAsynchronousAgent
- Parameters:
continueNormal
- (optional)Continuation
to be called when the backlog has been reduced back to normal- Returns:
- true if the underlying communication channel is backlogged; false otherwise
-
drainBacklog
public long drainBacklog(long cMillis) Description copied from interface:FlowControl
Check for an excessive backlog and allow blocking the calling thread for up to the specified amount of time.- Specified by:
drainBacklog
in interfaceFlowControl
- Overrides:
drainBacklog
in classAsynchronousAgent
- Parameters:
cMillis
- the maximum amount of time to wait (in milliseconds), or zero for infinite wait- Returns:
- the remaining timeout or a negative value if timeout has occurred (the return of zero is only allowed for infinite timeout and indicates that the backlog is no longer excessive)
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) - Specified by:
cancel
in interfaceFuture
- Overrides:
cancel
in classAsynchronousAgent
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture
- Overrides:
isCancelled
in classAsynchronousAgent
-
isDone
public boolean isDone()- Specified by:
isDone
in interfaceFuture
- Overrides:
isDone
in classAsynchronousAgent
-
get
- Specified by:
get
in interfaceFuture
- Overrides:
get
in classAsynchronousAgent
- Throws:
InterruptedException
ExecutionException
-
get
public Object get(long cTimeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture
- Overrides:
get
in classAsynchronousAgent
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
getResult
Description copied from class:AsynchronousAgent
Helper method that callsAsynchronousAgent.get()
and re-throws checked exceptions as a RuntimeException.- Overrides:
getResult
in classAsynchronousAgent
- Returns:
- the result value
-
getException
Description copied from class:AsynchronousAgent
Helper method that returns an exception (if completed exceptionally).- Overrides:
getException
in classAsynchronousAgent
- Returns:
- the exception or null if the operation completed successfully
-
isCompletedExceptionally
public boolean isCompletedExceptionally()Description copied from class:AsynchronousAgent
Helper method to check if the operation failed.- Overrides:
isCompletedExceptionally
in classAsynchronousAgent
- Returns:
- true if the operation failed
-
getCompletableFuture
Description copied from class:AsynchronousAgent
Get the CompletableFuture.- Overrides:
getCompletableFuture
in classAsynchronousAgent
- Returns:
- CompletableFuture
-