Rio Project 4.2 API Documentation



org.rioproject.monitor
Class ServiceResourceSelector

java.lang.Object
  extended by org.rioproject.monitor.ServiceResourceSelector
All Implemented Interfaces:
LeaseListener
Direct Known Subclasses:
LeastActiveSelector, ResourceCostSelector, RoundRobinSelector

public abstract class ServiceResourceSelector
extends Object
implements LeaseListener

This abstract class defines the semantics for selecting a ServiceResource based on requirements contained within a ServiceElement. Additionally, this interface defines semantics for the removal and snapshot retrieval of ServiceResource objects under its control.

Objects which implement this interface will need to create a Collection to manage the ServiceResource elements it is notified of. The managed Collection will back the Collection of ServiceResource elements which are leased and managed by the LandlordLessor

The LandlordLessor will send notifications of the following:

It is the responsibility of the entity to register with the LandlordLessor. The object that implements this interface should define the actions to take upon receipt of such notifications

Concrete implementations of this class must provide a zero-argument constructor in order to be instantiated by the ProvisionMonitor

Author:
Dennis Reedy

Field Summary
protected  Collection<LeasedResource> collection
          The collection of ServiceResource objects to manage
protected  Object collectionLock
           
protected  LandlordLessor landlord
          The LandlordLessor which will be registered to, and will provide Lease notification events
 
Constructor Summary
ServiceResourceSelector()
           
 
Method Summary
protected  void add(LeasedResource resource)
          If the Collection backed by the concrete class requires processing other then that defined by Collection.add override this method to provide the appropriate semantics
 void expired(LeasedResource resource)
          Notifies the manager of a lease expiration
 ServiceResource getServiceResource(ServiceElement sElem)
          This method will attempt to identify an available ServiceResource based on the operational criteria specified by a ServiceBean
 ServiceResource getServiceResource(ServiceElement sElem, Uuid uuid, boolean inclusive)
          This method will attempt to identify an available ServiceResource based on the operational criteria specified by a ServiceBean
 ServiceResource[] getServiceResources(ServiceElement sElem)
          Get all available ServiceResource instances that support the ServiceElement object's contained requirement specifications
 void register(LeasedResource resource)
          Notifies the manager of a new lease being created.
protected  void remove(LeasedResource resource)
          If the Collection backed by the concrete class requires processing other then that defined by Collection.remove override this method to provide the appropriate semantics
 void removed(LeasedResource resource)
          Notifies the manager of a lease removal
 void renewed(LeasedResource resource)
          Notifies the manager of a lease being renewed.
protected  ServiceResource selectServiceResource(ServiceElement sElem, ServiceResource[] svcResources)
          Select a ServiceResource for dynamic ServiceBean provisioning based on the operational criteria of a ServiceBean
abstract  void serviceResourceSelected(ServiceResource resource)
          This method allows concrete implementations of this class to order the Collection of ServiceResource instances based on a ServiceResource being selected
 void setLandlordLessor(LandlordLessor landlord)
          Set the LandlordLessor the ServiceResourceSelector will register to.
protected  void update(LeasedResource resource)
          If the Collection backed by the concrete class requires processing other then that defined by Collection.add override this method to provide the appropriate semantics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collection

protected Collection<LeasedResource> collection
The collection of ServiceResource objects to manage


collectionLock

protected final Object collectionLock

landlord

protected LandlordLessor landlord
The LandlordLessor which will be registered to, and will provide Lease notification events

Constructor Detail

ServiceResourceSelector

public ServiceResourceSelector()
Method Detail

setLandlordLessor

public void setLandlordLessor(LandlordLessor landlord)
Set the LandlordLessor the ServiceResourceSelector will register to.

Parameters:
landlord - The LandlordLessor

getServiceResource

public ServiceResource getServiceResource(ServiceElement sElem)
                                   throws Exception
This method will attempt to identify an available ServiceResource based on the operational criteria specified by a ServiceBean

Parameters:
sElem - The ServiceElement
Returns:
If a ServiceResource object can be identified, return the ServiceResource, otherwise return null
Throws:
Exception - If there are errors getting a ServiceResource

getServiceResource

public ServiceResource getServiceResource(ServiceElement sElem,
                                          Uuid uuid,
                                          boolean inclusive)
                                   throws Exception
This method will attempt to identify an available ServiceResource based on the operational criteria specified by a ServiceBean

Parameters:
sElem - The ServiceElement
uuid - The Uuid of the InstantiatorResource to either include or not include
inclusive - Either include or exclude the uuid from the selection. If true, include the uuid otherwise exclude the uuid
Returns:
If a ServiceResource object can be identified, otherwise return null
Throws:
Exception - if any errors occur selecting a resource

selectServiceResource

protected ServiceResource selectServiceResource(ServiceElement sElem,
                                                ServiceResource[] svcResources)
                                         throws ProvisionException
Select a ServiceResource for dynamic ServiceBean provisioning based on the operational criteria of a ServiceBean

Parameters:
sElem - The ServiceElement
svcResources - Array ServiceResource candidates
Returns:
If a ServiceResource object can be identified, otherwise return null
Throws:
ProvisionException - If there are unrecoverable errors provisioning the service

serviceResourceSelected

public abstract void serviceResourceSelected(ServiceResource resource)
This method allows concrete implementations of this class to order the Collection of ServiceResource instances based on a ServiceResource being selected

Parameters:
resource - A ServiceResource instance selected for provisioning a ServiceBean

getServiceResources

public ServiceResource[] getServiceResources(ServiceElement sElem)
                                      throws ProvisionException
Get all available ServiceResource instances that support the ServiceElement object's contained requirement specifications

Parameters:
sElem - The ServiceElement
Returns:
Array of ServiceResource instances that support the requirements
Throws:
ProvisionException - If there are unrecoverable errors provisioning the service

expired

public void expired(LeasedResource resource)
Notifies the manager of a lease expiration

Specified by:
expired in interface LeaseListener
Parameters:
resource - The resource associated with the expiration

removed

public void removed(LeasedResource resource)
Notifies the manager of a lease removal

Specified by:
removed in interface LeaseListener
Parameters:
resource - The resource associated with the removal

register

public void register(LeasedResource resource)
Notifies the manager of a new lease being created.

Specified by:
register in interface LeaseListener
Parameters:
resource - The resource associated with the new Lease.

renewed

public void renewed(LeasedResource resource)
Notifies the manager of a lease being renewed.

Specified by:
renewed in interface LeaseListener
Parameters:
resource - The resource associated with the new Lease.

add

protected void add(LeasedResource resource)
If the Collection backed by the concrete class requires processing other then that defined by Collection.add override this method to provide the appropriate semantics

Parameters:
resource - The LeasedResource to add

remove

protected void remove(LeasedResource resource)
If the Collection backed by the concrete class requires processing other then that defined by Collection.remove override this method to provide the appropriate semantics

Parameters:
resource - The LeasedResource to remove

update

protected void update(LeasedResource resource)
If the Collection backed by the concrete class requires processing other then that defined by Collection.add override this method to provide the appropriate semantics

Parameters:
resource - The LeasedResource

Copyright © Rio Project.

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