Class ContinuousQueryCache.ConverterAsynchronousProcessor
- java.lang.Object
-
- com.tangosol.util.AsynchronousAgent<T>
-
- com.tangosol.util.processor.AbstractAsynchronousProcessor<K,V,R,Map<K,R>>
-
- com.tangosol.util.processor.AsynchronousProcessor
-
- com.tangosol.net.cache.ContinuousQueryCache.ConverterAsynchronousProcessor
-
- All Implemented Interfaces:
FlowControl
,InvocableMap.EntryProcessor
,Serializable
,Future
- Enclosing class:
- ContinuousQueryCache<K,V_BACK,V_FRONT>
protected class ContinuousQueryCache.ConverterAsynchronousProcessor extends AsynchronousProcessor
Wraps anAsynchronousProcessor
to ensure the result of the EntryProcessor execution is deserialized prior to passing to the provided AsynchronousProcessor.- Since:
- 12.2.1.4
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Converter
f_convUp
Converter to deserializeBinary
values.protected AsynchronousProcessor
f_processor
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
Constructors Constructor Description ConverterAsynchronousProcessor(AsynchronousProcessor processor)
Construct the processor to wrap the providedAsynchronousProcessor
in order to ensure results are properly converted prior to return.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.Object
get()
Object
get(long cTimeout, TimeUnit unit)
CompletableFuture
getCompletableFuture()
Get the CompletableFuture.Throwable
getException()
Helper method that returns an exception (if completed exceptionally).InvocableMap.EntryProcessor
getProcessor()
Obtain the underlying entry processor.Object
getResult()
Helper method that callsAsynchronousAgent.get()
and re-throws checked exceptions as a RuntimeException.int
getUnitOfOrderId()
Return a unit-of-order id associated with this processor.boolean
isCancelled()
boolean
isCompletedExceptionally()
Helper method to check if the operation failed.boolean
isDone()
void
onComplete()
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
onResult(Map.Entry entry)
Called when there is a partial result of the asynchronous execution.Object
process(InvocableMap.Entry entry)
Not supported.Map
processAll(Set setEntries)
Not supported.-
Methods inherited from class com.tangosol.util.AsynchronousAgent
complete, completeExceptionally
-
-
-
-
Field Detail
-
f_processor
protected final AsynchronousProcessor f_processor
The delegateAsynchronousProcessor
.
-
-
Constructor Detail
-
ConverterAsynchronousProcessor
public ConverterAsynchronousProcessor(AsynchronousProcessor processor)
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 Detail
-
onResult
public void onResult(Map.Entry entry)
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
public void onException(Throwable eReason)
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:
AbstractAsynchronousAggregator.getUnitOfOrderId()
,AbstractAsynchronousProcessor.getUnitOfOrderId()
-
getProcessor
public InvocableMap.EntryProcessor getProcessor()
Description copied from class:AbstractAsynchronousProcessor
Obtain the underlying entry processor.- Overrides:
getProcessor
in classAbstractAsynchronousProcessor
- Returns:
- the underlying entry processor
-
process
public Object process(InvocableMap.Entry entry)
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
public Map processAll(Set setEntries)
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
public void bind(FlowControl control)
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
public boolean checkBacklog(Continuation continueNormal)
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
public Object get() throws InterruptedException, ExecutionException
- 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
public Object 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
public Throwable 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
public CompletableFuture getCompletableFuture()
Description copied from class:AsynchronousAgent
Get the CompletableFuture.- Overrides:
getCompletableFuture
in classAsynchronousAgent
- Returns:
- CompletableFuture
-
-