Class ClusteredRegistration
java.lang.Object
com.oracle.coherence.concurrent.executor.ClusteredRegistration
- All Implemented Interfaces:
TaskExecutorService.Registration
,MapListener
,EventListener
public class ClusteredRegistration
extends Object
implements TaskExecutorService.Registration, MapListener
A cluster-based implementation of an
TaskExecutorService.Registration
.- Since:
- 21.12
- Author:
- bo
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.oracle.coherence.concurrent.executor.TaskExecutorService.Registration
TaskExecutorService.Registration.Option
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClusteredExecutorService
TheTaskExecutorService
that created theTaskExecutorService.Registration
.protected final ExecutorService
The localExecutorService
that was registered.protected final AtomicBoolean
Track whetherclose()
has been called.protected final AtomicBoolean
Track whethershutdown()
has been called.protected final MapListener
Listener to detect changes on the cache entry for theExecutor
.protected final ConcurrentHashMap
<String, ClusteredRegistration.TaskExecutor> TheClusteredRegistration.TaskExecutor
s representing theTask
s scheduled for execution with theExecutor
.protected final OptionsByType
<TaskExecutorService.Registration.Option> TheTaskExecutorService.Registration.Option
s for theExecutor
.protected final String
The identity of the registeredExecutor
.static long
The delay between attempts to update theTaskExecutorService.ExecutorInfo
.static TimeUnit
The delayTimeUnit
forINFO_UPDATE_DELAY
.protected NamedCache
<String, ClusteredRegistration.TaskExecutor> TheClusteredRegistration.TaskExecutor
NamedCache
reference used byclose()
to avoid callingensureCache
on a service thread when terminating and executor.protected long
The tasks completed count.protected long
The tasks in progress count.protected long
The tasks rejected count.protected ClusteredRegistration.ExecutorMBeanImpl
The MBean for the registered executor.protected ScheduledFuture
AScheduledFuture
representing theTaskExecutorService.ExecutorInfo
updater to update the status in the cluster.protected ScheduledFuture
AScheduledFuture
representing theTaskExecutorService.ExecutorInfo
touch updater to trigger checking for remaining assigned tasks during graceful close.protected NamedCache
static boolean
The executor attribute to indicate whether trace logging is enabled.Fields inherited from interface com.tangosol.util.MapListener
ASYNCHRONOUS, SYNCHRONOUS, VERSION_AWARE
-
Constructor Summary
ConstructorsConstructorDescriptionClusteredRegistration
(ClusteredExecutorService clusteredExecutorService, String sExecutorId, ExecutorService executor, OptionsByType<TaskExecutorService.Registration.Option> optionsByType) Constructs aClusteredRegistration
. -
Method Summary
Modifier and TypeMethodDescriptionprotected NamedCache
Return theNamedCache
storingClusteredAssignment
instances.protected void
cleanupTask
(String sTaskId) Removes the task from the known task executors and adjusts metrics accordingly.void
close()
Closes theExecutor
.void
entryDeleted
(MapEvent mapEvent) Invoked when a map entry has been removed.void
entryInserted
(MapEvent mapEvent) Invoked when a map entry has been inserted.void
entryUpdated
(MapEvent mapEvent) Invoked when a map entry has been updated.protected void
executingTask
(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId) Execute the task and handle error/exception.protected NamedCache
Return theNamedCache
storingClusteredExecutorInfo
instances.protected static String
getExecutorServiceMBeanName
(Registry registry, String sName) Get the MBean name for thenamed
executor.getId()
Obtains the unique identity for the registeredExecutorService
.<T extends TaskExecutorService.Registration.Option>
TObtains theTaskExecutorService.Registration.Option
of the specified class when theExecutorService
was registered, or the default value if not found.long
Return the number of completed tasks.long
Return the number of tasks in progress.long
Return the number of rejected tasks.protected static void
registerExecutorMBean
(CacheService service, ExecutorMBean mbean, String sName) Registers the provided MBean for the specified executor.void
shutdown()
Gracefully close theExecutor
.protected void
start()
Starts theTaskExecutorService.Registration
for theExecutor
, allowing assignedTask
s to be executed andTaskExecutorService.ExecutorInfo
state to be updated.protected NamedCache
tasks()
Return theNamedCache
storingClusteredTaskManager
instances.protected static void
unregisterExecutiveServiceMBean
(CacheService service, String sName) Unregisters the MBean for the specified executor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.util.MapListener
characteristics, isAsynchronous, isSynchronous, isVersionAware, synchronous
-
Field Details
-
INFO_UPDATE_DELAY
public static long INFO_UPDATE_DELAYThe delay between attempts to update theTaskExecutorService.ExecutorInfo
. -
INFO_UPDATE_DELAY_UNIT
The delayTimeUnit
forINFO_UPDATE_DELAY
. -
s_fTraceLogging
public static boolean s_fTraceLoggingThe executor attribute to indicate whether trace logging is enabled.By default, the executor trace logging is disabled. logging can be enabled by either setting the
coherence.executor.trace.logging
system property or theTraceLogging
attribute on the JMX ExecutorMBean or viaManagement over REST
. -
f_listener
Listener to detect changes on the cache entry for theExecutor
. -
f_fShutdownCalled
Track whethershutdown()
has been called. -
f_fCloseCalled
Track whetherclose()
has been called. -
m_cTasksCompletedCount
protected long m_cTasksCompletedCountThe tasks completed count. -
m_cTasksRejectedCount
protected long m_cTasksRejectedCountThe tasks rejected count. -
m_cTasksInProgressCount
protected long m_cTasksInProgressCountThe tasks in progress count. -
f_clusteredExecutorService
TheTaskExecutorService
that created theTaskExecutorService.Registration
. -
f_sExecutorId
-
f_executor
The localExecutorService
that was registered. -
f_optionsByType
TheTaskExecutorService.Registration.Option
s for theExecutor
. -
m_scheduledFuture
AScheduledFuture
representing theTaskExecutorService.ExecutorInfo
updater to update the status in the cluster. -
m_touchFuture
AScheduledFuture
representing theTaskExecutorService.ExecutorInfo
touch updater to trigger checking for remaining assigned tasks during graceful close. -
m_viewAssignments
-
m_cacheTasksTermination
TheClusteredRegistration.TaskExecutor
NamedCache
reference used byclose()
to avoid callingensureCache
on a service thread when terminating and executor. -
f_mapTaskExecutors
TheClusteredRegistration.TaskExecutor
s representing theTask
s scheduled for execution with theExecutor
. -
m_executorMBean
The MBean for the registered executor.
-
-
Constructor Details
-
ClusteredRegistration
public ClusteredRegistration(ClusteredExecutorService clusteredExecutorService, String sExecutorId, ExecutorService executor, OptionsByType<TaskExecutorService.Registration.Option> optionsByType) Constructs aClusteredRegistration
.- Parameters:
clusteredExecutorService
- theTaskExecutorService
that owns theTaskExecutorService.Registration
sExecutorId
- the identity of the registeredExecutorService
executor
- the registeredExecutor
optionsByType
- theTaskExecutorService.Registration.Option
s for theExecutor
-
-
Method Details
-
getId
Description copied from interface:TaskExecutorService.Registration
Obtains the unique identity for the registeredExecutorService
.- Specified by:
getId
in interfaceTaskExecutorService.Registration
- Returns:
- the unique identity
-
getOption
public <T extends TaskExecutorService.Registration.Option> T getOption(Class<T> classOfOption, T defaultIfNotFound) Description copied from interface:TaskExecutorService.Registration
Obtains theTaskExecutorService.Registration.Option
of the specified class when theExecutorService
was registered, or the default value if not found.- Specified by:
getOption
in interfaceTaskExecutorService.Registration
- Type Parameters:
T
- the type of theTaskExecutorService.Registration.Option
- Parameters:
classOfOption
- the class ofTaskExecutorService.Registration.Option
defaultIfNotFound
- the value to return if not found- Returns:
- a
TaskExecutorService.Registration.Option
-
getTasksCompletedCount
public long getTasksCompletedCount()Return the number of completed tasks.- Returns:
- the number of completed tasks.
-
getTasksRejectedCount
public long getTasksRejectedCount()Return the number of rejected tasks.- Returns:
- the number of rejected tasks.
-
getTasksInProgressCount
public long getTasksInProgressCount()Return the number of tasks in progress.- Returns:
- the number of tasks in progress
-
entryInserted
Description copied from interface:MapListener
Invoked when a map entry has been inserted.- Specified by:
entryInserted
in interfaceMapListener
- Parameters:
mapEvent
- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListener
Invoked when a map entry has been updated.- Specified by:
entryUpdated
in interfaceMapListener
- Parameters:
mapEvent
- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListener
Invoked when a map entry has been removed.- Specified by:
entryDeleted
in interfaceMapListener
- Parameters:
mapEvent
- the MapEvent carrying the delete information
-
shutdown
public void shutdown()Gracefully close theExecutor
. Existing assigned tasks will not be canceled. -
executors
Return theNamedCache
storingClusteredExecutorInfo
instances.- Returns:
- the
NamedCache
storingClusteredExecutorInfo
instances
-
tasks
Return theNamedCache
storingClusteredTaskManager
instances.- Returns:
- the
NamedCache
storingClusteredTaskManager
instances
-
assignments
Return theNamedCache
storingClusteredAssignment
instances.- Returns:
- the
NamedCache
storingClusteredAssignment
instances
-
registerExecutorMBean
protected static void registerExecutorMBean(CacheService service, ExecutorMBean mbean, String sName) Registers the provided MBean for the specified executor.- Parameters:
service
- the cache servicembean
- the mbean to registersName
- the executor name- Throws:
NullPointerException
- if any ofservice
,mbean
, orsName
isnull
-
unregisterExecutiveServiceMBean
Unregisters the MBean for the specified executor.- Parameters:
service
- the cache servicesName
- the executor name- Throws:
NullPointerException
- if eitherservice
orsName
isnull
-
getExecutorServiceMBeanName
Get the MBean name for thenamed
executor.- Parameters:
registry
- the management registrysName
- the executor name- Returns:
- the MBean name for the
named
executor - Throws:
NullPointerException
- if eitherregistry
orsName
isnull
-
executingTask
protected void executingTask(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId) Execute the task and handle error/exception.- Parameters:
taskExecutor
- theClusteredRegistration.TaskExecutor
sExecId
- the executor IDsTaskId
- the task ID
-
cleanupTask
Removes the task from the known task executors and adjusts metrics accordingly.- Parameters:
sTaskId
- the task ID- Since:
- 22.06
-
start
protected void start()Starts theTaskExecutorService.Registration
for theExecutor
, allowing assignedTask
s to be executed andTaskExecutorService.ExecutorInfo
state to be updated. -
close
public void close()Closes theExecutor
.- Specified by:
close
in interfaceTaskExecutorService.Registration
-