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 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 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 NamedCachem_assignmentsCacheprotected 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.static booleans_fTraceLoggingThe executor attribute to indicate whether trace logging is enabled.-
Fields inherited from interface com.tangosol.util.MapListener
ASYNCHRONOUS, SYNCHRONOUS, VERSION_AWARE
-
-
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 voidclose()Closes theExecutor.voidentryDeleted(MapEvent mapEvent)voidentryInserted(MapEvent mapEvent)voidentryUpdated(MapEvent mapEvent)protected voidexecutingTask(ClusteredRegistration.TaskExecutor taskExecutor, String sExecId, String sTaskId)Execute the task and handle error/exception.protected static StringgetExecutorServiceMBeanName(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(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 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, wait
-
Methods inherited from interface com.tangosol.util.MapListener
characteristics, isAsynchronous, isSynchronous, isVersionAware, synchronous
-
-
-
-
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. You can enable it by either setting the "coherence.executor.trace.logging" system property or the "TraceLogging" attribute in ExecutorMBean through JMX or management over REST.
-
f_listener
protected final 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_assignmentsCache
protected NamedCache m_assignmentsCache
-
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(MapEvent mapEvent)
- Specified by:
entryInsertedin interfaceMapListener
-
entryUpdated
public void entryUpdated(MapEvent mapEvent)
- Specified by:
entryUpdatedin interfaceMapListener
-
entryDeleted
public void entryDeleted(MapEvent mapEvent)
- Specified by:
entryDeletedin interfaceMapListener
-
shutdown
public void shutdown()
Gracefully close theExecutor. Existing assigned tasks will not be canceled.
-
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
protected static void unregisterExecutiveServiceMBean(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(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
-
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
-
-