Class ClusteredTaskInterceptor

  • All Implemented Interfaces:
    com.tangosol.net.events.EventInterceptor

    public class ClusteredTaskInterceptor
    extends Object
    implements com.tangosol.net.events.EventInterceptor
    A ClusteredTaskManager event interceptor that orders the incoming tasks and put them in pending state when the orchestrated tasks reaches given capacity. Dispatches the pending tasks in a batch at a time as orchestrated tasks complete.
    Since:
    21.12
    Author:
    bo, lh
    • Field Detail

      • f_atomicPartsPending

        protected final AtomicReference<com.tangosol.net.partition.PartitionSet> f_atomicPartsPending
        Atomic reference for the partition set containing partitions that have pending tasks.
      • f_sequences

        protected final AtomicLongArray f_sequences
        An array that keeps track of the task sequences for each partition.
      • f_cMaxBatch

        protected final int f_cMaxBatch
        The maximum batch size.
      • f_cMaxAllowedTasks

        protected final int f_cMaxAllowedTasks
        The maximum tasks allowed to be run.
      • f_cOrchestratedTasks

        protected final AtomicInteger f_cOrchestratedTasks
        The number of orchestrated tasks.
      • f_fPendingTasks

        protected final AtomicBoolean f_fPendingTasks
        A flag to indicate whether there are pending tasks.
      • f_cacheService

        protected final com.tangosol.net.DistributedCacheService f_cacheService
        The cache service this interceptor is associated with.
      • f_mapPendingTasks

        protected final ConcurrentHashMap<Integer,​com.tangosol.util.LongArray<String>> f_mapPendingTasks
        A map of pending Tasks for each partition that contains sequence to task key mapping.
      • m_nLastPartitionId

        protected int m_nLastPartitionId
        The last partition ID processed.
    • Constructor Detail

      • ClusteredTaskInterceptor

        public ClusteredTaskInterceptor​(String sServiceName)
        Parameters:
        sServiceName - the service name the interceptor is registered with
    • Method Detail

      • addKey

        protected void addKey​(com.tangosol.util.LongArray<String> keyMap,
                              long sequence,
                              String key)
        Add an entry to the key map.
        Parameters:
        keyMap - the sequence to key map
        sequence - the sequence
        key - the task key
      • addPending

        public void addPending​(int nPid)
        Add the given partition to the set of partitions with pending work. This is invoked when the first new task with the given partition ID is added.
        Parameters:
        nPid - the id that has pending task
      • removePending

        protected boolean removePending​(int nPid)
        Remove the given partition from the set of partitions with pending work. This is invoked when a task is completed.
        Parameters:
        nPid - the id of the partition that is no longer present on this member
        Returns:
        true if the given partition ID is removed from the PartitionSet; false otherwise
      • getCacheService

        public com.tangosol.net.CacheService getCacheService()
        Return the associated CacheService.
        Returns:
        the associated CacheService
      • getSequence

        public long getSequence​(int nPartitionId)
        Gets the Task sequence number of a given partition.
        Parameters:
        nPartitionId - partition ID
        Returns:
        the Task sequence number
      • getNextSequence

        public long getNextSequence​(int nPartitionId)
        Gets the next Task sequence number of a given partition.
        Parameters:
        nPartitionId - partition ID
        Returns:
        the next available Task sequence number
      • resetSequence

        public long resetSequence​(int nPartitionId)
        Resets the Task sequence number of a given partition.
        Parameters:
        nPartitionId - partition ID
        Returns:
        the reset Task sequence number
      • getLastPartitionId

        public int getLastPartitionId()
        Returns the last partition ID of pending tasks processed.
        Returns:
        the last partition ID processed
      • setLastPartitionId

        public void setLastPartitionId​(int nPartitionId)
        Set the last partition ID of the pending tasks processed.
        Parameters:
        nPartitionId - partition ID
      • getBatchMax

        public int getBatchMax()
        Returns the maximum batch size.
        Returns:
        the maximum batch size
      • onEvent

        public void onEvent​(com.tangosol.net.events.Event event)
        Specified by:
        onEvent in interface com.tangosol.net.events.EventInterceptor