Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::ACS::MasterComponentImpl::SubsysResourceMonitor Class Reference

List of all members.

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

Detailed Description

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.

Author:
hsommer
Since:
ACS 6.0


Constructor & Destructor Documentation

alma::ACS::MasterComponentImpl::SubsysResourceMonitor::SubsysResourceMonitor Logger  logger,
ThreadFactory  threadFactory
[inline, package]
 

Ctor, with default value for delaySeconds = 10.

See also:
SubsysResourceMonitor(Logger, ThreadFactory, int)

alma::ACS::MasterComponentImpl::SubsysResourceMonitor::SubsysResourceMonitor Logger  logger,
ThreadFactory  threadFactory,
int  defaultDelaySeconds
[inline, package]
 

Parameters:
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).


Member Function Documentation

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.

Parameters:
timeout the timeout for waiting that the internal threads, queues, jobs etc are freed, or 0 to not wait at all.
unit 
Exceptions:
InterruptedException 

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.

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.

Returns:
the corresponding ResourceCheckRunner, or null if no runner matches.

<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.

Parameters:
checker 
delaySeconds determines the delay between ending a check call and starting the next one. If <1, then the default is used.
Exceptions:
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.

<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.

void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::resume  )  [inline]
 

Resumes monitoring of all resources.

This method has no effect if monitoring has not been previously suspended.

See also:
suspend()

void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::stopMonitoring String  resourceName  )  [inline]
 

Stops monitoring a given resource.

Parameters:
resourceName unique resource name

void alma::ACS::MasterComponentImpl::SubsysResourceMonitor::stopMonitoringAll  )  [inline]
 

Stops monitoring all resources.

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.


Member Data Documentation

final int alma::ACS::MasterComponentImpl::SubsysResourceMonitor::defaultDelaySeconds
 

The delay between two monitoring calls to resource.

boolean alma::ACS::MasterComponentImpl::SubsysResourceMonitor::isShutDown [private]
 

boolean alma::ACS::MasterComponentImpl::SubsysResourceMonitor::isShuttingDown [private]
 

final Logger alma::ACS::MasterComponentImpl::SubsysResourceMonitor::logger [private]
 

final ExecutorService alma::ACS::MasterComponentImpl::SubsysResourceMonitor::monitorCallThreadPool [private]
 

final Random alma::ACS::MasterComponentImpl::SubsysResourceMonitor::random [private]
 

final Set<ResourceCheckRunner> alma::ACS::MasterComponentImpl::SubsysResourceMonitor::resourceRunners [private]
 

final ScheduledThreadPoolExecutor alma::ACS::MasterComponentImpl::SubsysResourceMonitor::scheduler [private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:54:04 2009 for ACS Java API by doxygen 1.3.8