org.rhq.core.pluginapi.availability
Class AvailabilityCollectorRunnable

java.lang.Object
  extended by org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable
All Implemented Interfaces:
Runnable

public class AvailabilityCollectorRunnable
extends Object
implements Runnable

A class that can be used by plugins whose components may not be able to collect availability statuses fast enough. Typically, availability checks are very fast (sub-second). However, the plugin container puts a time limit on how long it will wait for a plugin's resource component to return availability status from calls to AvailabilityFacet.getAvailability(). This time limit is typically on the order of several seconds. The purpose of this time limit is to avoid having a rogue or misbehaving plugin from causing delays in availability reporting for the rest of the resources being managed within the system. This class provides an implementation to help resource components that can't guarantee how fast its availability checks will be. Some managed resources simply can't respond to avaiability checks fast enough. In this case, this class will provide an asynchronous method that will collect availability without a timeout being involved (in other words, availability will be retrieved by waiting as long as it takes). In order to tell the plugin container what the managed resource's current availability is, this class will provide a fast method to return the last known availability of the resource. In other words, it will be able to return the last know availability that was last retrieved by the asynchronous task - this retrieval of the last known availability will be very fast.


Field Summary
static long MIN_INTERVAL
          The minimum interval allowed between availability checks, in milliseconds.
 
Constructor Summary
AvailabilityCollectorRunnable(AvailabilityFacet availabilityChecker, long interval, ClassLoader contextClassloader, Executor threadPool)
          Creates a collector instance that will perform availability checking for a particular managed resource.
 
Method Summary
 AvailabilityType getLastKnownAvailability()
          This returns the last known availability status that was most recently retrieved from the managed resource.
 void run()
          Performs the actual availability checking.
 void start()
          For those resource components using this availability collector utility, their ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext) method must call this to start the availability checking that this object performs.
 void stop()
          For those resource components using this availability collector utility, their ResourceComponent#stop() method must call this to stop the availability checking that this object performs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_INTERVAL

public static final long MIN_INTERVAL
The minimum interval allowed between availability checks, in milliseconds.

See Also:
Constant Field Values
Constructor Detail

AvailabilityCollectorRunnable

public AvailabilityCollectorRunnable(AvailabilityFacet availabilityChecker,
                                     long interval,
                                     ClassLoader contextClassloader,
                                     Executor threadPool)
Creates a collector instance that will perform availability checking for a particular managed resource. The interval is the time, in milliseconds, this collector will wait between availability checks. This is the amount of time this collector will sleep after each time an availability check returned with the latest status. A typically value should be something around 1 minute but if an availability check takes alot of system resources to perform or adversely affects the managed resource if performed too often, you can make this longer. The shortest value allowed, however, is MIN_INTERVAL.

Parameters:
availabilityChecker - the object that is used to periodically check the managed resource (must not be null)
interval - the interval, in millis, between checking availabilities.
contextClassloader - the context classloader that will be used when checking availability
threadPool - the thread pool to be used to submit this runnable when it needs to start
Method Detail

getLastKnownAvailability

public AvailabilityType getLastKnownAvailability()
This returns the last known availability status that was most recently retrieved from the managed resource. This will not perform a live check on the managed resource; instead, it immediately returns the last known state of the managed resource. For those resource components using this availability collector utility, their AvailabilityFacet.getAvailability() method should simply be calling this method.

Returns:
AvailabilityType.UP if the resource can be accessed; otherwise AvailabilityType.DOWN

start

public void start()
For those resource components using this availability collector utility, their ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext) method must call this to start the availability checking that this object performs.


stop

public void stop()
For those resource components using this availability collector utility, their ResourceComponent#stop() method must call this to stop the availability checking that this object performs.


run

public void run()
Performs the actual availability checking. This is the method that is invoked after this runnable is submitted to the thread pool. You should not be calling this method directly - use start() instead.

Specified by:
run in interface Runnable


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.