Class ClusteredRegistration
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.ClusteredRegistration
-
- All Implemented Interfaces:
TaskExecutorService.Registration,com.tangosol.util.MapListener,EventListener
public class ClusteredRegistration extends Object implements TaskExecutorService.Registration, com.tangosol.util.MapListener
A cluster-based implementation of anTaskExecutorService.Registration.- Since:
- 21.12
- Author:
- bo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classClusteredRegistration.ExecutorMBeanImplExecutorMBeanimplementation.protected classClusteredRegistration.TaskExecutor-
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.executor.TaskExecutorService.Registration
TaskExecutorService.Registration.Option
-
-
Field Summary
Fields Modifier and Type Field Description protected ClusteredExecutorServicef_clusteredExecutorServiceTheTaskExecutorServicethat created theTaskExecutorService.Registration.protected ExecutorServicef_executorThe localExecutorServicethat was registered.protected AtomicBooleanf_fCloseCalledTrack whetherclose()has been called.protected AtomicBooleanf_fShutdownCalledTrack whethershutdown()has been called.protected com.tangosol.util.MapListenerf_listenerListener to detect changes on the cache entry for theExecutor.protected ConcurrentHashMap<String,ClusteredRegistration.TaskExecutor>f_mapTaskExecutorsTheClusteredRegistration.TaskExecutors representing theTasks scheduled for execution with theExecutor.protected OptionsByType<TaskExecutorService.Registration.Option>f_optionsByTypeTheTaskExecutorService.Registration.Options for theExecutor.protected Stringf_sExecutorIdThe identity of the registeredExecutor.static longINFO_UPDATE_DELAYThe delay between attempts to update theTaskExecutorService.ExecutorInfo.static TimeUnitINFO_UPDATE_DELAY_UNITThe delayTimeUnitforINFO_UPDATE_DELAY.protected com.tangosol.net.NamedCache<String,ClusteredRegistration.TaskExecutor>m_cacheTasksTerminationTheClusteredRegistration.TaskExecutorNamedCachereference used byclose()to avoid callingensureCacheon a service thread when terminating and executor.protected longm_cTasksCompletedCountThe tasks completed count.protected longm_cTasksInProgressCountThe tasks in progress count.protected longm_cTasksRejectedCountThe tasks rejected count.protected ClusteredRegistration.ExecutorMBeanImplm_executorMBeanThe MBean for the registered executor.protected ScheduledFuturem_scheduledFutureAScheduledFuturerepresenting theTaskExecutorService.ExecutorInfoupdater to update the status in the cluster.protected ScheduledFuturem_touchFutureAScheduledFuturerepresenting theTaskExecutorService.ExecutorInfotouch updater to trigger checking for remaining assigned tasks during graceful close.protected com.tangosol.net.NamedCachem_viewAssignmentsstatic booleans_fTraceLoggingThe executor attribute to indicate whether trace logging is enabled.
-
Constructor Summary
Constructors Constructor Description ClusteredRegistration(ClusteredExecutorService clusteredExecutorService, String sExecutorId, ExecutorService executor, OptionsByType<TaskExecutorService.Registration.Option> optionsByType)Constructs aClusteredRegistration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.tangosol.net.NamedCacheassignments()Return theNamedCachestoringClusteredAssignmentinstances.protected voidcleanupTask(String sTaskId)Removes the task from the known task executors and adjusts metrics accordingly.voidclose()Closes theExecutor.voidentryDeleted(com.tangosol.util.MapEvent mapEvent)voidentryInserted(com.tangosol.util.MapEvent mapEvent)voidentryUpdated(com.tangosol.util.MapEvent mapEvent)protected voidexecutingTask(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId)Execute the task and handle error/exception.protected com.tangosol.net.NamedCacheexecutors()Return theNamedCachestoringClusteredExecutorInfoinstances.protected static StringgetExecutorServiceMBeanName(com.tangosol.net.management.Registry registry, String sName)Get the MBean name for thenamedexecutor.StringgetId()Obtains the unique identity for the registeredExecutorService.<T extends TaskExecutorService.Registration.Option>
TgetOption(Class<T> classOfOption, T defaultIfNotFound)Obtains theTaskExecutorService.Registration.Optionof the specified class when theExecutorServicewas registered, or the default value if not found.longgetTasksCompletedCount()Return the number of completed tasks.longgetTasksInProgressCount()Return the number of tasks in progress.longgetTasksRejectedCount()Return the number of rejected tasks.protected static voidregisterExecutorMBean(com.tangosol.net.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 com.tangosol.net.NamedCachetasks()Return theNamedCachestoringClusteredTaskManagerinstances.protected static voidunregisterExecutiveServiceMBean(com.tangosol.net.CacheService service, String sName)Unregisters the MBean for the specified executor.
-
-
-
Field Detail
-
INFO_UPDATE_DELAY
public static long INFO_UPDATE_DELAY
The delay between attempts to update theTaskExecutorService.ExecutorInfo.
-
INFO_UPDATE_DELAY_UNIT
public static TimeUnit INFO_UPDATE_DELAY_UNIT
The delayTimeUnitforINFO_UPDATE_DELAY.
-
s_fTraceLogging
public static boolean s_fTraceLogging
The 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
protected final com.tangosol.util.MapListener f_listener
Listener to detect changes on the cache entry for theExecutor.
-
f_fShutdownCalled
protected final AtomicBoolean f_fShutdownCalled
Track whethershutdown()has been called.
-
f_fCloseCalled
protected final AtomicBoolean f_fCloseCalled
Track whetherclose()has been called.
-
m_cTasksCompletedCount
protected long m_cTasksCompletedCount
The tasks completed count.
-
m_cTasksRejectedCount
protected long m_cTasksRejectedCount
The tasks rejected count.
-
m_cTasksInProgressCount
protected long m_cTasksInProgressCount
The tasks in progress count.
-
f_clusteredExecutorService
protected final ClusteredExecutorService f_clusteredExecutorService
TheTaskExecutorServicethat created theTaskExecutorService.Registration.
-
f_executor
protected final ExecutorService f_executor
The localExecutorServicethat was registered.
-
f_optionsByType
protected final OptionsByType<TaskExecutorService.Registration.Option> f_optionsByType
TheTaskExecutorService.Registration.Options for theExecutor.
-
m_scheduledFuture
protected volatile ScheduledFuture m_scheduledFuture
AScheduledFuturerepresenting theTaskExecutorService.ExecutorInfoupdater to update the status in the cluster.
-
m_touchFuture
protected volatile ScheduledFuture m_touchFuture
AScheduledFuturerepresenting theTaskExecutorService.ExecutorInfotouch updater to trigger checking for remaining assigned tasks during graceful close.
-
m_viewAssignments
protected com.tangosol.net.NamedCache m_viewAssignments
-
m_cacheTasksTermination
protected com.tangosol.net.NamedCache<String,ClusteredRegistration.TaskExecutor> m_cacheTasksTermination
TheClusteredRegistration.TaskExecutorNamedCachereference used byclose()to avoid callingensureCacheon a service thread when terminating and executor.
-
f_mapTaskExecutors
protected final ConcurrentHashMap<String,ClusteredRegistration.TaskExecutor> f_mapTaskExecutors
TheClusteredRegistration.TaskExecutors representing theTasks scheduled for execution with theExecutor.
-
m_executorMBean
protected ClusteredRegistration.ExecutorMBeanImpl m_executorMBean
The MBean for the registered executor.
-
-
Constructor Detail
-
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 Detail
-
getId
public String 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
public void entryInserted(com.tangosol.util.MapEvent mapEvent)
- Specified by:
entryInsertedin interfacecom.tangosol.util.MapListener
-
entryUpdated
public void entryUpdated(com.tangosol.util.MapEvent mapEvent)
- Specified by:
entryUpdatedin interfacecom.tangosol.util.MapListener
-
entryDeleted
public void entryDeleted(com.tangosol.util.MapEvent mapEvent)
- Specified by:
entryDeletedin interfacecom.tangosol.util.MapListener
-
shutdown
public void shutdown()
Gracefully close theExecutor. Existing assigned tasks will not be canceled.
-
executors
protected com.tangosol.net.NamedCache executors()
Return theNamedCachestoringClusteredExecutorInfoinstances.- Returns:
- the
NamedCachestoringClusteredExecutorInfoinstances
-
tasks
protected com.tangosol.net.NamedCache tasks()
Return theNamedCachestoringClusteredTaskManagerinstances.- Returns:
- the
NamedCachestoringClusteredTaskManagerinstances
-
assignments
protected com.tangosol.net.NamedCache assignments()
Return theNamedCachestoringClusteredAssignmentinstances.- Returns:
- the
NamedCachestoringClusteredAssignmentinstances
-
registerExecutorMBean
protected static void registerExecutorMBean(com.tangosol.net.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
protected static void unregisterExecutiveServiceMBean(com.tangosol.net.CacheService service, String sName)Unregisters the MBean for the specified executor.- Parameters:
service- the cache servicesName- the executor name- Throws:
NullPointerException- if eitherserviceorsNameisnull
-
getExecutorServiceMBeanName
protected static String getExecutorServiceMBeanName(com.tangosol.net.management.Registry registry, String sName)
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
protected void cleanupTask(String sTaskId)
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
-
-