org.rhq.core.pluginapi.availability
Interface AvailabilityContext


public interface AvailabilityContext

Resource specific context through which to make availability related calls back into the plugin container.


Method Summary
 AvailabilityCollectorRunnable createAvailabilityCollectorRunnable(AvailabilityFacet availChecker, long interval)
          Under certain circumstances, a resource component may want to perform asynchronous availability checks, as opposed to AvailabilityFacet.getAvailability() blocking waiting for the managed resource to return its availability status.
 void disable()
          This method allows the component to request the server set the resource DISABLED in the same way that a user can set a resource DISABLED.
 void enable()
          This method allows the component to request the server set the resource ENABLED in the same way that a user can set a resource ENABLED.
 AvailabilityType getLastReportedAvailability()
          This method will return the last reported AvailabilityType, which can be null if not yet reported.
 void requestAvailabilityCheck()
          The plugin container (PC) checks resource availability based on the collection interval on the {code}AvailabilityType{code} metric.
 

Method Detail

createAvailabilityCollectorRunnable

AvailabilityCollectorRunnable createAvailabilityCollectorRunnable(AvailabilityFacet availChecker,
                                                                  long interval)
Under certain circumstances, a resource component may want to perform asynchronous availability checks, as opposed to AvailabilityFacet.getAvailability() blocking waiting for the managed resource to return its availability status. Using asynchronous availability checking frees the resource component from having to guarantee that the managed resource will provide availability status in a timely fashion. If the resource component needs to perform asynchronous availability checking, it should call this method to create an instance of AvailabilityCollectorRunnable inside the ResourceComponent.start(org.rhq.core.pluginapi.inventory.ResourceContext) method. It should then call the returned object's AvailabilityCollectorRunnable.start() method within the same resource component ResourceComponent.start(ResourceContext) method. The resource component should call the AvailabilityCollectorRunnable.stop() method when the resource component stops. The resource component's AvailabilityFacet.getAvailability() method should simply return the value returned by AvailabilityCollectorRunnable.getLastKnownAvailability(). This method will be extremely fast since it simply returns the last availability that was retrieved by the given availability checker. Only when the availability checker finishes checking for availability of the managed resource (however long it takes to do so) will the last known availability state change. For more information, read the javadoc in AvailabilityCollectorRunnable.

Parameters:
availChecker - the object that will perform the actual check of the managed resource's availability
interval - the interval, in milliseconds, between availability checks. The minimum value allowed for this parameter is AvailabilityCollectorRunnable.MIN_INTERVAL.
Returns:
the availability collector runnable that will perform the asynchronous checking

requestAvailabilityCheck

void requestAvailabilityCheck()
The plugin container (PC) checks resource availability based on the collection interval on the {code}AvailabilityType{code} metric. At times the plugin may want the PC to request an availability check be done prior to the next scheduled check time. For example, Start/Stop/Restart operation implementations may want to request that the PC check availability sooner rather than later, to pick up the new lifecycle state. This method should be used sparingly, and should not in general override the scheduled avail checks.


getLastReportedAvailability

AvailabilityType getLastReportedAvailability()
This method will return the last reported AvailabilityType, which can be null if not yet reported. This method *does not* invoke a call to {link AvailabilityFacet.getAvailability(), raher it will return the result of the most recent call to that method, made by the plugin container.

Returns:
the last reported availability type, or null if not yet reported.

disable

void disable()
This method allows the component to request the server set the resource DISABLED in the same way that a user can set a resource DISABLED. This should be used with care by component code as it will mean that alerting and availability reporting will essentionally be ignored for the resource until it is again enabled. A user is free to enable a resource disabled by the component code. If the resource is already disabled then the call has no effect.

See Also:
#enable()}

enable

void enable()
This method allows the component to request the server set the resource ENABLED in the same way that a user can set a resource ENABLED. This should be used with care by component code as it does not care how the resource was DISABLED. It can override a user action. If the resource is already disabled then the call has no effect.

See Also:
#disable()}


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.