Class ClusteredTaskManager<T,​A,​R>

  • Type Parameters:
    T - the Task type
    A - the mutable accumulation type of the reduction operation by the Task.Collector
    R - the result type of the reduction operation performed by the Task.Collector
    All Implemented Interfaces:
    LiveObject, com.tangosol.io.ExternalizableLite, com.tangosol.io.pof.PortableObject, Serializable

    public class ClusteredTaskManager<T,​A,​R>
    extends Object
    implements com.tangosol.io.ExternalizableLite, LiveObject, com.tangosol.io.pof.PortableObject
    Manages the definition and current state of an individual Task being orchestrated by an TaskExecutorService.
    Since:
    21.12
    Author:
    bo
    See Also:
    Serialized Form
    • Field Detail

      • m_sTaskId

        protected String m_sTaskId
        The unique identity of the Task.
      • m_lTaskSequence

        protected volatile long m_lTaskSequence
        The partition based sequence number of the Task.
      • m_nPartitionId

        protected int m_nPartitionId
        The partition ID of the Task.
      • m_completionPredicate

        protected com.tangosol.util.function.Remote.Predicate<? super R> m_completionPredicate
        The Remote.Predicate to determine if the Task is complete, based on a collected result.
      • m_fRunCompletionRunnable

        protected boolean m_fRunCompletionRunnable
        A flag to indicate whether to run the completionRunnable or not.
      • m_retainDuration

        protected Duration m_retainDuration
        The Duration to retain the Task after it is complete.
      • m_cPendingExecutionStrategyUpdateCount

        protected int m_cPendingExecutionStrategyUpdateCount
        The number of events/updates/changes that have occurred since the last time the ExecutionStrategy was evaluated, which may impact the ExecutionPlan.
      • m_cPendingExecutionPlanOptimizationCount

        protected int m_cPendingExecutionPlanOptimizationCount
        The number of potential optimizations that can occurred to the ExecutionPlan since it was last optimized.
      • m_lastResult

        protected volatile Result<R> m_lastResult
        The last collected result for the Task.
      • m_nResultVersion

        protected int m_nResultVersion
        The lastResult version represented by a monotonically increasing integer value.
      • m_lCurrentResultGeneration

        protected long m_lCurrentResultGeneration
        Monotonically increasing generation counter indicating how many times a result was provided.
      • m_lProcessedResultGeneration

        protected long m_lProcessedResultGeneration
        The generation counter of the last time the results were evaluated.
      • m_fCompleted

        protected volatile boolean m_fCompleted
        A flag to indicate if the Task is now completed, in which case no further results will be accepted and no future updates will be published.
      • m_fCancelled

        protected volatile boolean m_fCancelled
        A flag to indicate if the Task is now cancelled, in which case no further results will be accepted and no future updates will be published.
    • Method Detail

      • onProcess

        public ComposableContinuation onProcess​(com.tangosol.net.CacheService service,
                                                com.tangosol.util.InvocableMap.Entry entry,
                                                Cause cause)
        Returns a ComposableContinuation to invoke based on the current state. This may return null if no continuation is needed.
        Parameters:
        service - the associated CacheService
        entry - the cache InvocableMap.Entry for the task being processed
        cause - the Cause triggered an update
        Returns:
        a ComposableContinuation to invoke based on the current state or null if no continuation is needed
      • isOwner

        public boolean isOwner​(String executorId)
        Determines if an Executor has been allocated the Task.
        Parameters:
        executorId - the Executor ID
        Returns:
        true if the Executor with the specified identifier has been allocated the Task, false otherwise.
      • getTaskId

        public String getTaskId()
        Obtains the unique identity of the Task.
        Returns:
        the unique identity of the Task
      • setRunCompletionRunnable

        public void setRunCompletionRunnable​(boolean value)
        Sets the flag to indicate if we need to run the Task.CompletionRunnable.
        Parameters:
        value - the flag to indicate if we need to run the Task.CompletionRunnable
      • getRetainDuration

        public Duration getRetainDuration()
        Obtains the Duration to retain the Task after it is complete.
        Returns:
        the Duration
      • asyncProcessChanges

        public void asyncProcessChanges​(com.tangosol.net.CacheService service,
                                        String key,
                                        Cause cause)
        Asynchronously processes the changes that have recently occurred on the ClusteredTaskManager.
        Parameters:
        service - the CacheService that owns the ClusteredTaskManager state
        key - the NamedCache key for the ClusteredTaskManager
        cause - the underlying event Cause that triggered the processing
      • getTask

        public Task<T> getTask()
        Obtains the Task to be executed.
        Returns:
        the Task
      • isCompleted

        public boolean isCompleted()
        Determines if the Task has completed execution and can now be removed.
        Returns:
        true if the Task has completed execution, false otherwise
      • isCancelled

        public boolean isCancelled()
        Determines if the Task has been cancelled.
        Returns:
        true if the Task has been cancelled, false otherwise
      • isDone

        public boolean isDone()
        Returns true if the Task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
        Returns:
        true the associated Task has is done false otherwise
      • getLastResult

        public Result<R> getLastResult()
        Get the last collected Result.
        Returns:
        the last collected Result
      • getResultVersion

        public int getResultVersion()
        Get the version number of the latest result.
        Returns:
        the version number of the latest result
      • getPartitionId

        public int getPartitionId()
        Gets the partition ID.
        Returns:
        the partition ID.
      • setPartitionId

        public void setPartitionId​(int nPartitionId)
        Sets the Task partition ID.
        Parameters:
        nPartitionId - the Task partition ID to set to
      • getTaskSequence

        public long getTaskSequence()
        Gets the partition based Task sequence number.
        Returns:
        the partition based Task sequence number
      • setTaskSequence

        public void setTaskSequence​(long sequence)
        Sets the partition based Task sequence number.
        Parameters:
        sequence - the Task sequence number to set to
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • readExternal

        public void readExternal​(com.tangosol.io.pof.PofReader in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(com.tangosol.io.pof.PofWriter out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException
      • getParentSpanContext

        protected com.tangosol.internal.tracing.SpanContext getParentSpanContext()
        Return the SpanContext of the span that enqueued this task.
        Returns:
        the SpanContext of the span that enqueued this task
        Since:
        22.06
      • asyncEvaluateResult

        protected boolean asyncEvaluateResult​(Result<R> originalResult)
        Evaluate the result of the Task given the current Results made by each of the assigned Executor(s), returning if a result change occurred.
        Parameters:
        originalResult - the original Result to evaluate
        Returns:
        true if a new result is available, false otherwise
      • cleanup

        protected void cleanup​(com.tangosol.net.CacheService service,
                               String sKey)
        Cleanup metadata associated with the given task key.
        Parameters:
        service - the associated CacheService
        sKey - the task key
      • cleanProperties

        protected void cleanProperties​(com.tangosol.net.CacheService service)
        Clean up the task properties.
        Parameters:
        service - the CacheService