
Classes | |
| class | ComponentChecker< T extends ACSComponent > |
| class | PingableResourceChecker< T extends PingableResourceOperations > |
| interface | ResourceChecker< T > |
| class | ResourceCheckRunner< T > |
| interface | ResourceErrorHandler< T > |
Public Member Functions | |
| int | getNumberOfMonitorTasks () |
| void | suspend () |
| void | resume () |
| void | stopMonitoring (String resourceName) |
| void | stopMonitoringAll () |
Public Attributes | |
| final int | defaultDelaySeconds |
Package Functions | |
| SubsysResourceMonitor (Logger logger, ThreadFactory threadFactory) | |
| SubsysResourceMonitor (Logger logger, ThreadFactory threadFactory, int defaultDelaySeconds) | |
| < T > void | monitorResource (ResourceChecker< T > checker, ResourceErrorHandler< T > err) |
| < T > void | monitorResource (ResourceChecker< T > checker, ResourceErrorHandler< T > err, int delaySeconds) |
| SubsysResourceMonitor.ResourceCheckRunner | getResourceCheckRunner (ResourceChecker checker) |
| synchronized void | destroy (long timeout, TimeUnit unit) throws InterruptedException |
Private Attributes | |
| final ScheduledThreadPoolExecutor | scheduler |
| final Random | random |
| final Logger | logger |
| final ExecutorService | monitorCallThreadPool |
| final Set< ResourceCheckRunner > | resourceRunners |
| boolean | isShuttingDown |
| boolean | isShutDown |
Monitor for any kind of resource whose state a subsystem master component wants to observe.
This class is used by MasterComponentImplBase and should not be exposed to subsystem developers directly. However, the contained interfaces SubsysResourceMonitor.ResourceChecker and SubsysResourceMonitor.ResourceErrorHandler can be implemented by master components to supply customized checkers and error handlers for various resource types and error recovery strategies.
| alma::ACS::MasterComponentImpl::SubsysResourceMonitor::SubsysResourceMonitor | ( | Logger | logger, | |
| ThreadFactory | threadFactory | |||
| ) | [inline, package] |
Ctor, with default value for delaySeconds = 10.
| alma::ACS::MasterComponentImpl::SubsysResourceMonitor::SubsysResourceMonitor | ( | Logger | logger, | |
| ThreadFactory | threadFactory, | |||
| int | defaultDelaySeconds | |||
| ) | [inline, package] |
| logger | Logger to be used by this object | |
| threadFactory | all threads for scheduling and calling the resources will be created by this factory. | |
| defaultDelaySeconds | the default delay between finishing one monitoring call and starting the next call to the same resource. Values <= 1 will be changed to == 1. This default can be overridden in method monitorResource(alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceChecker, alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceErrorHandler, int). |
References isShutDown, isShuttingDown, monitorCallThreadPool, random, resourceRunners, and scheduler.
| synchronized void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::destroy | ( | long | timeout, | |
| TimeUnit | unit | |||
| ) | throws InterruptedException [inline, package] |
Cancels monitoring of all resources and leaves this object in an unusable state.
Impl note: this method is synchronized so that a second call can return immediately, but only if the first call has finished.
| timeout | the timeout for waiting that the internal threads, queues, jobs etc are freed, or 0 to not wait at all. | |
| unit |
| InterruptedException |
References isShutDown, isShuttingDown, monitorCallThreadPool, and scheduler.
Referenced by alma::ACS::MasterComponentImpl::MasterComponentImplBase::cleanUp(), and alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::tearDown().
| int alma::ACS::MasterComponentImpl::SubsysResourceMonitor::getNumberOfMonitorTasks | ( | ) | [inline] |
For testing only. Returns the number of actively running threads, plus the number of tasks in the queue that is used for scheduling the monitoring calls.
References scheduler.
Referenced by alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testMonitorEasy(), alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testResourceUnavailable(), and alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testUsageErrorResponse().
| SubsysResourceMonitor.ResourceCheckRunner alma::ACS::MasterComponentImpl::SubsysResourceMonitor::getResourceCheckRunner | ( | ResourceChecker | checker | ) | [inline, package] |
For testing only!
Gets the ResourceCheckRunner that is used for running the monitor checks that use the given ResourceChecker.
ResourceCheckRunner, or null if no runner matches. References resourceRunners.
Referenced by alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testResourceUnavailable().
| <T> void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::monitorResource | ( | ResourceChecker< T > | checker, | |
| ResourceErrorHandler< T > | err, | |||
| int | delaySeconds | |||
| ) | [inline, package] |
Starts to periodically monitor the resource that checker contains. The monitor delay length is given by delaySeconds.
In order to randomize check times even if many resources get signed up for monitoring one after the other, the initial delay before the first check is run is taken randomly between 1 second and the period time.
| checker | ||
| delaySeconds | determines the delay between ending a check call and starting the next one. If <1, then the default is used. |
| IllegalStateException | if destroy(long, TimeUnit) has been called. | |
| IllegalArgumentException | if any of the arguments are null, or if checker.getResource() or checker.getResourceName() returns null. |
References defaultDelaySeconds, alma::ACS::MasterComponentImpl::SubsysResourceMonitor::ResourceChecker< T >::getResource(), alma::ACS::MasterComponentImpl::SubsysResourceMonitor::ResourceChecker< T >::getResourceName(), isShuttingDown, logger, monitorCallThreadPool, random, resourceRunners, and scheduler.
| <T> void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::monitorResource | ( | ResourceChecker< T > | checker, | |
| ResourceErrorHandler< T > | err | |||
| ) | [inline, package] |
Same as monitorResource(alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceChecker, alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceErrorHandler, int), but with the default delay instead of a delay parameter.
References defaultDelaySeconds.
Referenced by alma::ACS::MasterComponentImpl::MasterComponentImplBase::monitorResource(), alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testMonitorEasy(), alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testResourceCheckException(), alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testResourceUnavailable(), and alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testUsageErrorResponse().
| void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::resume | ( | ) | [inline] |
Resumes monitoring of all resources.
This method has no effect if monitoring has not been previously suspended.
References resourceRunners.
| void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::stopMonitoring | ( | String | resourceName | ) | [inline] |
Stops monitoring a given resource.
| resourceName | unique resource name |
References resourceRunners.
Referenced by alma::ACS::MasterComponentImpl::MasterComponentImplBase::stopMonitoringResource().
| void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::stopMonitoringAll | ( | ) | [inline] |
Stops monitoring all resources.
References resourceRunners.
Referenced by alma::ACS::MasterComponentImpl::MasterComponentImplBase::stopMonitoringAllResources().
| void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::suspend | ( | ) | [inline] |
Suspends monitoring of all resources until resume() is called. Currently running monitor calls do not get stopped, only future calls are prevented.
Note that the monitoring queue remains intact, while the monitor call itself becomes a no-op.
References resourceRunners.
The delay between two monitoring calls to resource.
Referenced by monitorResource().
boolean alma::ACS::MasterComponentImpl::SubsysResourceMonitor::isShutDown [private] |
Referenced by destroy(), and SubsysResourceMonitor().
boolean alma::ACS::MasterComponentImpl::SubsysResourceMonitor::isShuttingDown [private] |
Referenced by destroy(), monitorResource(), and SubsysResourceMonitor().
final Logger alma::ACS::MasterComponentImpl::SubsysResourceMonitor::logger [private] |
final ExecutorService alma::ACS::MasterComponentImpl::SubsysResourceMonitor::monitorCallThreadPool [private] |
Referenced by destroy(), monitorResource(), and SubsysResourceMonitor().
final Random alma::ACS::MasterComponentImpl::SubsysResourceMonitor::random [private] |
Referenced by monitorResource(), and SubsysResourceMonitor().
final Set<ResourceCheckRunner> alma::ACS::MasterComponentImpl::SubsysResourceMonitor::resourceRunners [private] |
Referenced by getResourceCheckRunner(), monitorResource(), resume(), stopMonitoring(), stopMonitoringAll(), SubsysResourceMonitor(), and suspend().
final ScheduledThreadPoolExecutor alma::ACS::MasterComponentImpl::SubsysResourceMonitor::scheduler [private] |
Referenced by destroy(), getNumberOfMonitorTasks(), monitorResource(), and SubsysResourceMonitor().
1.6.2