Class ClusteredTaskInterceptor
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.internal.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClusteredTaskInterceptor.SequenceComparatorComparator used to compare sequence number.static classClusteredTaskInterceptor.SetTaskStateProcessorAnInvocableMap.EntryProcessorto compare and set the state of aClusteredTaskManager, returning the previous state.
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReference<com.tangosol.net.partition.PartitionSet>f_atomicPartsPendingAtomic reference for the partition set containing partitions that have pending tasks.protected com.tangosol.net.DistributedCacheServicef_cacheServiceThe cache service this interceptor is associated with.protected intf_cMaxAllowedTasksThe maximum tasks allowed to be run.protected intf_cMaxBatchThe maximum batch size.protected AtomicIntegerf_cOrchestratedTasksThe number of orchestrated tasks.protected ExecutorServicef_executorServiceAnExecutorServiceon which to perform background operations.protected AtomicBooleanf_fPendingTasksA flag to indicate whether there are pending tasks.protected ConcurrentHashMap<Integer,com.tangosol.util.LongArray<String>>f_mapPendingTasksA map of pendingTasks for each partition that contains sequence to task key mapping.protected AtomicLongArrayf_sequencesAn array that keeps track of the task sequences for each partition.protected intm_nLastPartitionIdThe last partition ID processed.
-
Constructor Summary
Constructors Constructor Description ClusteredTaskInterceptor(String sServiceName)Constructs aClusteredTaskInterceptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddKey(com.tangosol.util.LongArray<String> keyMap, long sequence, String key)Add an entry to the key map.voidaddPending(int nPid)Add the given partition to the set of partitions with pending work.intgetBatchMax()Returns the maximum batch size.com.tangosol.net.CacheServicegetCacheService()Return the associatedCacheService.intgetLastPartitionId()Returns the last partition ID of pending tasks processed.longgetNextSequence(int nPartitionId)Gets the nextTasksequence number of a given partition.longgetSequence(int nPartitionId)Gets theTasksequence number of a given partition.voidonEvent(com.tangosol.net.events.Event event)protected booleanremovePending(int nPid)Remove the given partition from the set of partitions with pending work.longresetSequence(int nPartitionId)Resets theTasksequence number of a given partition.voidsetLastPartitionId(int nPartitionId)Set the last partition ID of the pending tasks processed.
-
-
-
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_executorService
protected final ExecutorService f_executorService
AnExecutorServiceon which to perform background operations.
-
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 pendingTasks 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)
Constructs aClusteredTaskInterceptor.- 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 mapsequence- the sequencekey- 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 associatedCacheService.- Returns:
- the associated
CacheService
-
getSequence
public long getSequence(int nPartitionId)
Gets theTasksequence number of a given partition.- Parameters:
nPartitionId- partition ID- Returns:
- the
Tasksequence number
-
getNextSequence
public long getNextSequence(int nPartitionId)
Gets the nextTasksequence number of a given partition.- Parameters:
nPartitionId- partition ID- Returns:
- the next available
Tasksequence number
-
resetSequence
public long resetSequence(int nPartitionId)
Resets theTasksequence number of a given partition.- Parameters:
nPartitionId- partition ID- Returns:
- the reset
Tasksequence 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:
onEventin interfacecom.tangosol.net.events.EventInterceptor
-
-