Rio Project 4.2 API Documentation



org.rioproject.sla
Class SLAPolicyHandler

java.lang.Object
  extended by org.rioproject.sla.SLAPolicyHandler
All Implemented Interfaces:
ThresholdListener
Direct Known Subclasses:
RedeployPolicyHandler, RelocationPolicyHandler, ScalingPolicyHandler

public class SLAPolicyHandler
extends Object
implements ThresholdListener

A SLAPolicyHandler handles thresholds for a ThresholdWatch, registering to a ThresholdManager. If a threshold is crossed (breached or cleared), the SLAPolicyHandler will fire a SLAThresholdEvent using an EventHandler provided The SLAPolicyHandler should be extended to provide logic on how to process specific policy (if-then-else logic) on how to manage SLA Thresholds produced by ThresholdWatch instantiations

Author:
Dennis Reedy

Field Summary
protected  ServiceBeanContext context
          ServiceBeanContext for the ServiceBean
protected  Object eventSource
          Event source object
protected  boolean initialized
          Flag which indicates the SLAPolicyHandler has initialized
protected  ThresholdManager thresholdManager
          The ThresholdManager the SLA is for
 
Constructor Summary
SLAPolicyHandler(SLA sla)
          Construct a SLAPolicyHandler
 
Method Summary
 void disconnect()
          Disconnect from the ThresholdManager
 Configuration getConfiguration()
          Get the Configuration object
 String getDescription()
          Get the description
protected  Object getEventSource()
          Get the source property
 String getID()
          Get the ID of the ThresholdWatch the ThresholdListener is associated to
protected  String getName()
           
 SLA getSLA()
          Get the SLA
 ThresholdManager getThresholdManager()
           
 void initialize(Object eventSource, EventHandler eventHandler, ServiceBeanContext context)
          Prepare the SLAPolicyHandler for processing.
 void notify(Calculable calculable, ThresholdValues thresholdValues, int type)
          Notify for a threshold event
protected  void notifyListeners(SLAPolicyEvent event)
          Notify all registered SLAPolicyEventListener instances
 void registerListener(SLAPolicyEventListener listener)
          Register for SLAPolicyEvent notifications
protected  void sendSLAThresholdEvent(Calculable calculable, ThresholdValues tValues, int type)
          Set up a SLAThresholdEvent and send it
protected  void setName(String name, long iID)
           
 void setSLA(SLA sla)
          Set or update the SLA
 void setThresholdManager(ThresholdManager thresholdManager)
          Set the ThresholdManager and connect to the ThresholdManager
 void unregisterListener(SLAPolicyEventListener listener)
          Unregister for SLAPolicyEvent notifications
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventSource

protected Object eventSource
Event source object


context

protected ServiceBeanContext context
ServiceBeanContext for the ServiceBean


thresholdManager

protected ThresholdManager thresholdManager
The ThresholdManager the SLA is for


initialized

protected boolean initialized
Flag which indicates the SLAPolicyHandler has initialized

Constructor Detail

SLAPolicyHandler

public SLAPolicyHandler(SLA sla)
Construct a SLAPolicyHandler

Parameters:
sla - The SLA for the SLAPolicyHandler
Method Detail

initialize

public void initialize(Object eventSource,
                       EventHandler eventHandler,
                       ServiceBeanContext context)
Prepare the SLAPolicyHandler for processing. The method will only set these values if the SLAPolicyHandler has not been initialized before

Parameters:
eventSource - The object to be used as the remote event source
eventHandler - Handler which sends events
context - The ServiceBeanContext
Throws:
IllegalArgumentException - if any of the parameters are null

getEventSource

protected Object getEventSource()
Get the source property

Returns:
The Object used as the event source

getDescription

public String getDescription()
Get the description

Returns:
String The descriptive attribute for this SLA Handler

setSLA

public void setSLA(SLA sla)
Set or update the SLA

Parameters:
sla - The SLA

getSLA

public SLA getSLA()
Get the SLA

Returns:
The SLA that the SLAPolicyHandler has been constructed with

getConfiguration

public Configuration getConfiguration()
                               throws ConfigurationException
Get the Configuration object

Returns:
The Configuration from the ServiceBeanContext. If the ServiceBeanContext is null, return an empty configuration
Throws:
ConfigurationException - If the configuration cannot be created

getID

public String getID()
Description copied from interface: ThresholdListener
Get the ID of the ThresholdWatch the ThresholdListener is associated to

Specified by:
getID in interface ThresholdListener
Returns:
The identifier (ID) of the ThresholdWatch the ThresholdListener is asscociated to
See Also:
ThresholdListener.getID()

setName

protected void setName(String name,
                       long iID)

getName

protected String getName()

setThresholdManager

public void setThresholdManager(ThresholdManager thresholdManager)
Description copied from interface: ThresholdListener
Set the ThresholdManager and connect to the ThresholdManager

Specified by:
setThresholdManager in interface ThresholdListener
Parameters:
thresholdManager - The ThresholdManager to connect to
See Also:
ThresholdListener.setThresholdManager(org.rioproject.watch.ThresholdManager)

getThresholdManager

public ThresholdManager getThresholdManager()
Returns:
Get the ThresholdManager

disconnect

public void disconnect()
Disconnect from the ThresholdManager


notify

public void notify(Calculable calculable,
                   ThresholdValues thresholdValues,
                   int type)
Description copied from interface: ThresholdListener
Notify for a threshold event

Specified by:
notify in interface ThresholdListener
Parameters:
calculable - The current metric
thresholdValues - The current thresholds
type - The type of threshold event, breached or cleared
See Also:
ThresholdListener.notify(org.rioproject.watch.Calculable, org.rioproject.watch.ThresholdValues, int)

registerListener

public void registerListener(SLAPolicyEventListener listener)
Register for SLAPolicyEvent notifications

Parameters:
listener - The SLAPolicyEventListener

unregisterListener

public void unregisterListener(SLAPolicyEventListener listener)
Unregister for SLAPolicyEvent notifications

Parameters:
listener - The SLAPolicyEventListener

notifyListeners

protected void notifyListeners(SLAPolicyEvent event)
Notify all registered SLAPolicyEventListener instances

Parameters:
event - The SLAPolicyEvent

sendSLAThresholdEvent

protected void sendSLAThresholdEvent(Calculable calculable,
                                     ThresholdValues tValues,
                                     int type)
Set up a SLAThresholdEvent and send it

Parameters:
calculable - The current metric
tValues - The current thresholds
type - The type of threshold event, breached or cleared

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.