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 ClusteredExecutorServiceTheTaskExecutorServicethat created theTaskExecutorService.Registration.protected final ExecutorServiceThe localExecutorServicethat was registered.protected final AtomicBooleanTrack whetherclose()has been called.protected final AtomicBooleanTrack whethershutdown()has been called.protected final MapListenerListener to detect changes on the cache entry for theExecutor.protected final ConcurrentHashMap<String, ClusteredRegistration.TaskExecutor> TheClusteredRegistration.TaskExecutors representing theTasks scheduled for execution with theExecutor.protected final OptionsByType<TaskExecutorService.Registration.Option> TheTaskExecutorService.Registration.Options for theExecutor.protected final StringThe identity of the registeredExecutor.static longThe delay between attempts to update theTaskExecutorService.ExecutorInfo.static TimeUnitThe delayTimeUnitforINFO_UPDATE_DELAY.protected NamedCache<String, ClusteredRegistration.TaskExecutor> TheClusteredRegistration.TaskExecutorNamedCachereference used byclose()to avoid callingensureCacheon a service thread when terminating and executor.protected longThe tasks completed count.protected longThe tasks in progress count.protected longThe tasks rejected count.protected ClusteredRegistration.ExecutorMBeanImplThe MBean for the registered executor.protected ScheduledFutureAScheduledFuturerepresenting theTaskExecutorService.ExecutorInfoupdater to update the status in the cluster.protected ScheduledFutureAScheduledFuturerepresenting theTaskExecutorService.ExecutorInfotouch updater to trigger checking for remaining assigned tasks during graceful close.protected NamedCachestatic booleanThe 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 NamedCacheReturn theNamedCachestoringClusteredAssignmentinstances.protected voidcleanupTask(String sTaskId) Removes the task from the known task executors and adjusts metrics accordingly.voidclose()Closes theExecutor.voidentryDeleted(MapEvent mapEvent) Invoked when a map entry has been removed.voidentryInserted(MapEvent mapEvent) Invoked when a map entry has been inserted.voidentryUpdated(MapEvent mapEvent) Invoked when a map entry has been updated.protected voidexecutingTask(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId) Execute the task and handle error/exception.protected NamedCacheReturn theNamedCachestoringClusteredExecutorInfoinstances.protected static StringgetExecutorServiceMBeanName(Registry registry, String sName) Get the MBean name for thenamedexecutor.getId()Obtains the unique identity for the registeredExecutorService.<T extends TaskExecutorService.Registration.Option>
TObtains theTaskExecutorService.Registration.Optionof the specified class when theExecutorServicewas registered, or the default value if not found.longReturn the number of completed tasks.longReturn the number of tasks in progress.longReturn the number of rejected tasks.protected static voidregisterExecutorMBean(CacheService service, ExecutorMBean mbean, String sName) Registers the provided MBean for the specified executor.voidshutdown()Gracefully close theExecutor.protected voidstart()Starts theTaskExecutorService.Registrationfor theExecutor, allowing assignedTasks to be executed andTaskExecutorService.ExecutorInfostate to be updated.protected NamedCachetasks()Return theNamedCachestoringClusteredTaskManagerinstances.protected static voidunregisterExecutiveServiceMBean(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, waitMethods 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 delayTimeUnitforINFO_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.loggingsystem property or theTraceLoggingattribute 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
TheTaskExecutorServicethat created theTaskExecutorService.Registration. -
f_sExecutorId
-
f_executor
The localExecutorServicethat was registered. -
f_optionsByType
TheTaskExecutorService.Registration.Options for theExecutor. -
m_scheduledFuture
AScheduledFuturerepresenting theTaskExecutorService.ExecutorInfoupdater to update the status in the cluster. -
m_touchFuture
AScheduledFuturerepresenting theTaskExecutorService.ExecutorInfotouch updater to trigger checking for remaining assigned tasks during graceful close. -
m_viewAssignments
-
m_cacheTasksTermination
TheClusteredRegistration.TaskExecutorNamedCachereference used byclose()to avoid callingensureCacheon a service thread when terminating and executor. -
f_mapTaskExecutors
TheClusteredRegistration.TaskExecutors representing theTasks 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- theTaskExecutorServicethat owns theTaskExecutorService.RegistrationsExecutorId- the identity of the registeredExecutorServiceexecutor- the registeredExecutoroptionsByType- theTaskExecutorService.Registration.Options for theExecutor
-
-
Method Details
-
getId
Description copied from interface:TaskExecutorService.RegistrationObtains the unique identity for the registeredExecutorService.- Specified by:
getIdin 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.RegistrationObtains theTaskExecutorService.Registration.Optionof the specified class when theExecutorServicewas registered, or the default value if not found.- Specified by:
getOptionin interfaceTaskExecutorService.Registration- Type Parameters:
T- the type of theTaskExecutorService.Registration.Option- Parameters:
classOfOption- the class ofTaskExecutorService.Registration.OptiondefaultIfNotFound- 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:MapListenerInvoked when a map entry has been inserted.- Specified by:
entryInsertedin interfaceMapListener- Parameters:
mapEvent- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListenerInvoked when a map entry has been updated.- Specified by:
entryUpdatedin interfaceMapListener- Parameters:
mapEvent- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListenerInvoked when a map entry has been removed.- Specified by:
entryDeletedin 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 theNamedCachestoringClusteredExecutorInfoinstances.- Returns:
- the
NamedCachestoringClusteredExecutorInfoinstances
-
tasks
Return theNamedCachestoringClusteredTaskManagerinstances.- Returns:
- the
NamedCachestoringClusteredTaskManagerinstances
-
assignments
Return theNamedCachestoringClusteredAssignmentinstances.- Returns:
- the
NamedCachestoringClusteredAssignmentinstances
-
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, orsNameisnull
-
unregisterExecutiveServiceMBean
Unregisters the MBean for the specified executor.- Parameters:
service- the cache servicesName- the executor name- Throws:
NullPointerException- if eitherserviceorsNameisnull
-
getExecutorServiceMBeanName
Get the MBean name for thenamedexecutor.- Parameters:
registry- the management registrysName- the executor name- Returns:
- the MBean name for the
namedexecutor - Throws:
NullPointerException- if eitherregistryorsNameisnull
-
executingTask
protected void executingTask(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId) Execute the task and handle error/exception.- Parameters:
taskExecutor- theClusteredRegistration.TaskExecutorsExecId- 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.Registrationfor theExecutor, allowing assignedTasks to be executed andTaskExecutorService.ExecutorInfostate to be updated. -
close
public void close()Closes theExecutor.- Specified by:
closein interfaceTaskExecutorService.Registration
-