public class ThreadMonitor extends Object
Runnable tasks provided to this
ThreadMonitor should respond to the standard Thread.interrupt() signal.
This mechanism will be used for coordinating shutdown of the task. All
ExecutorServices provided to this framework are assumed to respond to the system
shutdown signal, though this is not required for this framework to function.
Sadly though the question of "Who will guard the guards themselves?" is intentionally
avoided by this class and should be considered out of scope.ShutdownManager,
ShutdownManager| Constructor and Description |
|---|
ThreadMonitor(ExecutorService workPool,
org.forgerock.util.thread.listener.ShutdownManager shutdownManager,
Debug debug)
Create an instance of the ThreadMonitor with an assigned work pool of threads to use.
|
ThreadMonitor(ExecutorService workPool,
org.forgerock.util.thread.listener.ShutdownManager shutdownManager,
Debug debug,
int maxRecoveryDelayInMS,
int recoveryDelayDeltaInMS)
A constructor reserved for test.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getSuccessiveFailingCounter()
Get Successive failing counter for the test.
|
void |
watchScheduledThread(ScheduledExecutorService scheduledService,
Runnable runnable,
long delay,
long duration,
TimeUnit timeUnit)
Triggers the given runnable immediately to be executed at the scheduled time.
|
void |
watchThread(ExecutorService service,
Runnable runnable)
Triggers the given runnable to be executed immediately via the given ExecutorService.
|
@Inject public ThreadMonitor(ExecutorService workPool, org.forgerock.util.thread.listener.ShutdownManager shutdownManager, @Named(value="amThreadManager") Debug debug)
workPool - A sized ExecutorService which is larger enough to handle the expected
number of jobs it needs to monitor. This ExecutorService should be
generated using the ExecutorServiceFactory
to ensure it responds to the global System Shutdown event. Non null.shutdownManager - Required to detect shutdown signals.debug - Non null, required for signalling thread failure/restart.ExecutorServiceFactorypublic ThreadMonitor(ExecutorService workPool, org.forgerock.util.thread.listener.ShutdownManager shutdownManager, @Named(value="amThreadManager") Debug debug, int maxRecoveryDelayInMS, int recoveryDelayDeltaInMS)
workPool - A sized ExecutorService which is larger enough to handle the expected
number of jobs it needs to monitor. This ExecutorService should be
generated using the ExecutorServiceFactory
to ensure it responds to the global System Shutdown event. Non null.shutdownManager - Required to detect shutdown signals.debug - Non null, required for signalling thread failure/restart.maxRecoveryDelayInMS - Max recovery delay in msrecoveryDelayDeltaInMS - Recovery delay delta in msExecutorServiceFactorypublic void watchThread(ExecutorService service, Runnable runnable)
service - Non null service which will hold the runnable.runnable - Non null runnable to execute immediately.public void watchScheduledThread(ScheduledExecutorService scheduledService, Runnable runnable, long delay, long duration, TimeUnit timeUnit)
scheduledService - Non null scheduled service which will hold the runnable.runnable - Non null runnable to executed on a scheduled basis.delay - Start delay in the given TimeUnits.duration - Fixed delay in the given TimeUnits.timeUnit - TimeUnit for both delay and duration.ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, java.util.concurrent.TimeUnit)public int getSuccessiveFailingCounter()
Copyright © 2010–2023 Open Identity Platform Community. All rights reserved.