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 anAsynchronousProcessorto 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 Converterf_convUpConverter to deserializeBinaryvalues.protected AsynchronousProcessorf_processorThe 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 providedAsynchronousProcessorin order to ensure results are properly converted prior to return.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(FlowControl control)Bind this agent with the specified underlying FlowControl object.booleancancel(boolean mayInterruptIfRunning)booleancheckBacklog(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.longdrainBacklog(long cMillis)Check for an excessive backlog and allow blocking the calling thread for up to the specified amount of time.voidflush()Ensure that any buffered asynchronous operations are dispatched to the underlying tier.Objectget()Objectget(long cTimeout, TimeUnit unit)CompletableFuturegetCompletableFuture()Get the CompletableFuture.ThrowablegetException()Helper method that returns an exception (if completed exceptionally).InvocableMap.EntryProcessorgetProcessor()Obtain the underlying entry processor.ObjectgetResult()Helper method that callsAsynchronousAgent.get()and re-throws checked exceptions as a RuntimeException.intgetUnitOfOrderId()Return a unit-of-order id associated with this processor.booleanisCancelled()booleanisCompletedExceptionally()Helper method to check if the operation failed.booleanisDone()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 entry)Called when there is a partial result of the asynchronous execution.Objectprocess(InvocableMap.Entry entry)Not supported.MapprocessAll(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 providedAsynchronousProcessorin 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: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.
- Overrides:
onResultin 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: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.
- Overrides:
onExceptionin classAsynchronousProcessor- 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.
- Overrides:
onCompletein classAsynchronousProcessor
-
getUnitOfOrderId
public int getUnitOfOrderId()
Description copied from class:AbstractAsynchronousProcessorReturn 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
AsynchronousProcessorswith the same order id and the same key set, then the correspondingexecutionand 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
AsynchronousProcessorswith the same order id and the same partition set, then the the correspondingexecutionand calls toAbstractAsynchronousProcessor.onComplete()are going to happen in the exact same order.Note 1: The ordering guarantee is respected between
AsynchronousProcessorsandAsynchronousAggregators with the same unit-of-order id.
Note 2: There is no ordering guarantees between asynchronous and synchronous operations.- Overrides:
getUnitOfOrderIdin 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:AbstractAsynchronousProcessorObtain the underlying entry processor.- Overrides:
getProcessorin classAbstractAsynchronousProcessor- Returns:
- the underlying entry processor
-
process
public Object process(InvocableMap.Entry entry)
Description copied from class:AbstractAsynchronousProcessorNot supported.- Specified by:
processin interfaceInvocableMap.EntryProcessor- Overrides:
processin 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:AbstractAsynchronousProcessorNot supported.- Specified by:
processAllin interfaceInvocableMap.EntryProcessor- Overrides:
processAllin 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:AsynchronousAgentBind this agent with the specified underlying FlowControl object. This method is to be used only internally by the service.- Overrides:
bindin classAsynchronousAgent- Parameters:
control- the underlying FlowControl
-
flush
public void flush()
Description copied from interface:FlowControlEnsure that any buffered asynchronous operations are dispatched to the underlying tier.Note: this is a non-blocking call.
- Specified by:
flushin interfaceFlowControl- Overrides:
flushin classAsynchronousAgent
-
checkBacklog
public boolean checkBacklog(Continuation continueNormal)
Description copied from interface:FlowControlCheck 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:
checkBacklogin interfaceFlowControl- Overrides:
checkBacklogin classAsynchronousAgent- Parameters:
continueNormal- (optional)Continuationto 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:FlowControlCheck for an excessive backlog and allow blocking the calling thread for up to the specified amount of time.- Specified by:
drainBacklogin interfaceFlowControl- Overrides:
drainBacklogin 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:
cancelin interfaceFuture- Overrides:
cancelin classAsynchronousAgent
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture- Overrides:
isCancelledin classAsynchronousAgent
-
isDone
public boolean isDone()
- Specified by:
isDonein interfaceFuture- Overrides:
isDonein classAsynchronousAgent
-
get
public Object get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture- Overrides:
getin classAsynchronousAgent- Throws:
InterruptedExceptionExecutionException
-
get
public Object get(long cTimeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture- Overrides:
getin classAsynchronousAgent- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
getResult
public Object getResult()
Description copied from class:AsynchronousAgentHelper method that callsAsynchronousAgent.get()and re-throws checked exceptions as a RuntimeException.- Overrides:
getResultin classAsynchronousAgent- Returns:
- the result value
-
getException
public Throwable getException()
Description copied from class:AsynchronousAgentHelper method that returns an exception (if completed exceptionally).- Overrides:
getExceptionin classAsynchronousAgent- Returns:
- the exception or null if the operation completed successfully
-
isCompletedExceptionally
public boolean isCompletedExceptionally()
Description copied from class:AsynchronousAgentHelper method to check if the operation failed.- Overrides:
isCompletedExceptionallyin classAsynchronousAgent- Returns:
- true if the operation failed
-
getCompletableFuture
public CompletableFuture getCompletableFuture()
Description copied from class:AsynchronousAgentGet the CompletableFuture.- Overrides:
getCompletableFuturein classAsynchronousAgent- Returns:
- CompletableFuture
-
-