Rio Project 4.2 API Documentation



org.rioproject.sla
Class ScalingPolicyHandler

java.lang.Object
  extended by org.rioproject.sla.SLAPolicyHandler
      extended by org.rioproject.sla.ScalingPolicyHandler
All Implemented Interfaces:
Remote, ServerProxyTrust, ServiceProvisionListener, ThresholdListener

public class ScalingPolicyHandler
extends SLAPolicyHandler
implements ServiceProvisionListener, ServerProxyTrust

The ScalingPolicyHandler will increment and optionally decrement instances of the ServiceBean it is associated to based on limits set for the SLA. The ScalingPolicyHandler will look for attributes set that can control it's operational behavior,.

The ScalingPolicyHandler supports the following configuration entries; where each configuration entry name is associated with the component name scalingPolicyHandler

  • provisionListenerExporter
    Type:
    Exporter
    Default:
    A new BasicJeriExporter with
    • a TcpServerEndpoint created on a random port,
    • a BasicILFactory,
    • distributed garbage collection turned off,
    • keep alive on.
    Description:
    The Exporter used to export the ProvisionListener server. A new exporter is obtained every time a ScalablePolicyHandler needs to export itself.
  • Author:
    Dennis Reedy

    Field Summary
    static String DECREMENT_DESTROY_SENT
              Action that indicates that a decrement command with destroy set to true has been sent
    static String DECREMENT_FAILED
              Action that indicates that a decrement command failed to be sent
    static String INCREMENT_FAILURE
              Action that indicates an increment request has failed
    static String INCREMENT_PENDING
              Action that indicates an increment request is pending
    static String INCREMENT_SUCCEEDED
              Action that indicates an increment request has succeeded.
    protected  Calculable lastCalculable
              The last calculable
    protected  ThresholdValues lastThresholdValues
              The last ThresholdValue
    protected  int maxServices
              The maximum number of services to increment.
     
    Fields inherited from class org.rioproject.sla.SLAPolicyHandler
    context, eventSource, initialized, thresholdManager
     
    Constructor Summary
    ScalingPolicyHandler(SLA sla)
              Construct a ScalingPolicyHandler
     
    Method Summary
     void disconnect()
              Disconnect from the ThresholdManager
    protected  boolean doDecrement()
              Do the decrement
    protected  void doIncrement()
              Do the increment
     void failed(ServiceElement sElem, boolean resubmitted)
              Notify listener that the Service described by the ServiceElement has not been provision succesfully
     String getDescription()
              Get the description
    protected  int getPendingRequestCount(OperationalStringManager opMgr)
               
     TrustVerifier getProxyVerifier()
              Returns a TrustVerifier which can be used to verify that a given proxy to this policy handler can be trusted
    protected  ServiceElement getServiceElement()
               
    protected  int getTotalKnownServices()
               
     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
     void setSLA(SLA sla)
              Set or update the SLA
     void setThresholdManager(ThresholdManager thresholdManager)
              Set the ThresholdManager and connect to the ThresholdManager
     void succeeded(ServiceBeanInstance jsbInstance)
              Notify listener that the Service described by the ServiceBeanInstance has been provisioned succesfully
     
    Methods inherited from class org.rioproject.sla.SLAPolicyHandler
    getConfiguration, getEventSource, getID, getName, getSLA, getThresholdManager, notifyListeners, registerListener, sendSLAThresholdEvent, setName, unregisterListener
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    INCREMENT_PENDING

    public static final String INCREMENT_PENDING
    Action that indicates an increment request is pending

    See Also:
    Constant Field Values

    INCREMENT_FAILURE

    public static final String INCREMENT_FAILURE
    Action that indicates an increment request has failed

    See Also:
    Constant Field Values

    INCREMENT_SUCCEEDED

    public static final String INCREMENT_SUCCEEDED
    Action that indicates an increment request has succeeded. The resultant Object in the SLAPolicyEvent will be the proxy of the new service

    See Also:
    Constant Field Values

    DECREMENT_DESTROY_SENT

    public static final String DECREMENT_DESTROY_SENT
    Action that indicates that a decrement command with destroy set to true has been sent

    See Also:
    Constant Field Values

    DECREMENT_FAILED

    public static final String DECREMENT_FAILED
    Action that indicates that a decrement command failed to be sent

    See Also:
    Constant Field Values

    maxServices

    protected int maxServices
    The maximum number of services to increment. If the value is -1, then no limit has been set


    lastCalculable

    protected Calculable lastCalculable
    The last calculable


    lastThresholdValues

    protected ThresholdValues lastThresholdValues
    The last ThresholdValue

    Constructor Detail

    ScalingPolicyHandler

    public ScalingPolicyHandler(SLA sla)
    Construct a ScalingPolicyHandler

    Parameters:
    sla - The SLA for the ScalingPolicyHandler
    Method Detail

    getDescription

    public String getDescription()
    Description copied from class: SLAPolicyHandler
    Get the description

    Overrides:
    getDescription in class SLAPolicyHandler
    Returns:
    String The descriptive attribute for this SLA Handler

    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
    Overrides:
    setThresholdManager in class SLAPolicyHandler
    Parameters:
    thresholdManager - The ThresholdManager to connect to
    See Also:
    ThresholdListener.setThresholdManager(org.rioproject.watch.ThresholdManager)

    disconnect

    public void disconnect()
    Description copied from class: SLAPolicyHandler
    Disconnect from the ThresholdManager

    Overrides:
    disconnect in class SLAPolicyHandler

    setSLA

    public void setSLA(SLA sla)
    Description copied from class: SLAPolicyHandler
    Set or update the SLA

    Overrides:
    setSLA in class SLAPolicyHandler
    Parameters:
    sla - The SLA

    initialize

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

    Overrides:
    initialize in class SLAPolicyHandler
    Parameters:
    eventSource - The object to be used as the remote event source
    eventHandler - Handler which sends events
    context - The ServiceBeanContext

    getServiceElement

    protected ServiceElement getServiceElement()

    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
    Overrides:
    notify in class SLAPolicyHandler
    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)

    succeeded

    public void succeeded(ServiceBeanInstance jsbInstance)
                   throws RemoteException
    Description copied from interface: ServiceProvisionListener
    Notify listener that the Service described by the ServiceBeanInstance has been provisioned succesfully

    Specified by:
    succeeded in interface ServiceProvisionListener
    Parameters:
    jsbInstance - The ServiceBeanInstance
    Throws:
    RemoteException - If communication errors occur
    See Also:
    ServiceProvisionListener.succeeded(org.rioproject.core.ServiceBeanInstance)

    failed

    public void failed(ServiceElement sElem,
                       boolean resubmitted)
                throws RemoteException
    Description copied from interface: ServiceProvisionListener
    Notify listener that the Service described by the ServiceElement has not been provision succesfully

    Specified by:
    failed in interface ServiceProvisionListener
    Parameters:
    sElem - The ServiceElement
    resubmitted - Whether the Service described by the ServiceElement has been resubmitted for provisioning
    Throws:
    RemoteException - If communication errors occur
    See Also:
    ServiceProvisionListener.failed(org.rioproject.core.ServiceElement, boolean)

    getProxyVerifier

    public TrustVerifier getProxyVerifier()
    Returns a TrustVerifier which can be used to verify that a given proxy to this policy handler can be trusted

    Specified by:
    getProxyVerifier in interface ServerProxyTrust

    getPendingRequestCount

    protected int getPendingRequestCount(OperationalStringManager opMgr)

    getTotalKnownServices

    protected int getTotalKnownServices()
                                 throws Exception
    Throws:
    Exception

    doIncrement

    protected void doIncrement()
    Do the increment


    doDecrement

    protected boolean doDecrement()
    Do the decrement

    Returns:
    true if the decrement needs to be rescheduled

    Copyright © Rio Project.

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