Rio Project 4.2 API Documentation



org.rioproject.system
Class ComputeResource

java.lang.Object
  extended by java.util.Observable
      extended by org.rioproject.system.ComputeResource

public class ComputeResource
extends Observable

The ComputeResource represents an abstract notion of a compute resource that offers computational resources which can be measured using Quality of Service mechanisms which correlate to qualitative and quantitative capabilities such as CPU, Memory, and others

Author:
Dennis Reedy

Nested Class Summary
 class ComputeResource.CapabilityChannel
          The CapabilityChannel is an inner class that becomes an Observer to MeasurableCapability components and ends up notifying the ComputeResource to update registered Observer instances if any MeasurableCapability components have changed their state within the interval prescribed for the broadcaster
 
Constructor Summary
ComputeResource()
          Create a ComputeResource with a default (empty) configuration
ComputeResource(Configuration config)
          Create a ComputeResource
 
Method Summary
 boolean addMeasurableCapability(MeasurableCapability capability)
          Add a MeasurableCapability object.
 void addPlatformCapability(PlatformCapability pCap)
          Add a PlatformCapability object.
 void addThresholdListener(ThresholdListener listener)
          A helper method which will add a ThresholdListener to all contained MeasurableCapability components.
 void boot()
          Boot the ComputeResource, loading all PlatformCapability and MeasurableCapability instances
 InetAddress getAddress()
          Get the InetAddress ComputeResource object has been configured to represent
 ComputeResourceUtilization getComputeResourceUtilization()
          Get the ComputeResourceUtilization
 String getDescription()
          Get the description
 MeasurableCapability[] getMeasurableCapabilities()
          Return an array of MeasurableCapability objects.
 MeasurableCapability getMeasurableCapability(String description)
          Get a MeasurableCapability
 MeasuredResource[] getMeasuredResources()
          Get the MeasuredResource components for the ComputeResource
 boolean getPersistentProvisioning()
          Get the persistentProvisioning property
 String getPersistentProvisioningRoot()
          Get the location for the persistent provisioning of PlatformCapability instances
 PlatformCapability[] getPlatformCapabilities()
          Return an array of PlatformCapability objects.
 PlatformCapability getPlatformCapability(String name)
          Get a PlatformCapability
 Map<String,String> getPlatformCapabilityNameTable()
          Get the PlatformCapability name table
 long getReportInterval()
          Get the reportInterval property which controls how often the ComputeResource will inform registered Observers of a state change.
 ResourceCapability getResourceCapability()
          Return the ResourceCapabilityobject that will be used to communicate the platform and measurable capabilities attributes of the ComputeResource
 double getUtilization()
          Get the resource utilization as computed by a summation of the MeasurableCapability components
 boolean hasMeasurableCapability(MeasurableCapability capability)
          Determine if the MeasurableCapability exists in this ComputeResource
 boolean hasPlatformCapability(PlatformCapability capability)
          Determine if the PlatformCapability exists in this ComputeResource
 DownloadRecord[] provision(PlatformCapability pCap, StagedSoftware stagedSoftware)
          Provision a StagedSoftware for a PlatformCapability object.
 boolean removalInProcess(PlatformCapability pCap)
          Determine if a PlatformCapability is being removed from the system.
 boolean removeMeasurableCapability(MeasurableCapability capability)
          Remove a MeasurableCapability object.
 boolean removePlatformCapability(PlatformCapability pCap, boolean clean)
          Remove a PlatformCapability object.
 void removeThresholdListener(ThresholdListener listener)
          A helper method which will remove a ThresholdListener from all contained MeasurableCapability components.
 void setPersistentProvisioning(boolean persistentProvisioning)
          Set the persistentProvisioning property
 void setPersistentProvisioningRoot(String provisionRoot)
          Set the location for the persistent provisioning of PlatformCapability instances
 void setReportInterval(long reportInterval)
          Set the reportInterval property which controls how often the ComputeResource will inform registered Observers of a state change.
 void shutdown()
          Inform all MeasurableCapability instances to stop measuring
 void stateChange()
          Notify all registered Observers the ComputeResource has changed.
 void updateMeasurableCapability(MeasurableCapability capability)
          Update a MeasurableCapability object.
 void updatePlatformCapability(PlatformCapability capability)
          Update a PlatformCapability object.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComputeResource

public ComputeResource()
                throws ConfigurationException,
                       UnknownHostException
Create a ComputeResource with a default (empty) configuration

Throws:
ConfigurationException - If there are problems accessing the ComputeResource's configuration object
UnknownHostException - If the local host cannot be obtained

ComputeResource

public ComputeResource(Configuration config)
                throws ConfigurationException,
                       UnknownHostException
Create a ComputeResource

Parameters:
config - The Configuration used to initialize the ComputeResource
Throws:
ConfigurationException - If there are problems accessing the ComputeResource's configuration object
UnknownHostException - If the local host cannot be obtained
IllegalArgumentException - If the config is null
Method Detail

setReportInterval

public void setReportInterval(long reportInterval)
Set the reportInterval property which controls how often the ComputeResource will inform registered Observers of a state change. A state change is determined if any of the MeasurableCapability components contained within this ComputeResource provide an update in the interval specified by the reportIntervalProperty

Parameters:
reportInterval - The interval controlling when the ComputeResource reports change of state to registered Observers

getReportInterval

public long getReportInterval()
Get the reportInterval property which controls how often the ComputeResource will inform registered Observers of a state change. A state change is determined if any of the MeasurableCapability components contained within this ComputeResource provide an update in the interval specified by the reportInterval property

Returns:
The interval controlling when the ComputeResource reports change of state to registered Observers

getDescription

public String getDescription()
Get the description

Returns:
The description

getAddress

public InetAddress getAddress()
Get the InetAddress ComputeResource object has been configured to represent

Returns:
The InetAddress ComputeResource object has been configured to represent

addPlatformCapability

public void addPlatformCapability(PlatformCapability pCap)
Add a PlatformCapability object. The addition of a PlatformCapability component causes the state of this object to change, triggering the notification of all registered Observer instances.

If there is a PlatformCapability component that is equal to the provided PlatformCapability (according to the PlatformCapability.equals() contract), the existing PlatformCapability object will be remain unchanged and the provided PlatformCapability ignored

Parameters:
pCap - The PlatformCapability to add

provision

public DownloadRecord[] provision(PlatformCapability pCap,
                                  StagedSoftware stagedSoftware)
Provision a StagedSoftware for a PlatformCapability object. The provisioning of StagedSoftware object for aPlatformCapability component causes the state of this object to change, triggering the notification of all registered Observer instances.

If there is a PlatformCapability component that is equal to the provided PlatformCapability (according to the PlatformCapability.equals() contract), the existing PlatformCapability object will be changed. If the PlatformCapability object does not exist, it will be added

Parameters:
pCap - The PlatformCapability
stagedSoftware - StagedSoftware to provision for the PlatformCapability
Returns:
Array of DownloadRecord instances which represent any software downloaded to add the PlatformCapability. If no software was downloaded to add the PlatformCapability, return an empty array

hasPlatformCapability

public boolean hasPlatformCapability(PlatformCapability capability)
Determine if the PlatformCapability exists in this ComputeResource

Parameters:
capability - The PlatformCapability to check
Returns:
True if exists, false otherwise

updatePlatformCapability

public void updatePlatformCapability(PlatformCapability capability)
                              throws Exception
Update a PlatformCapability object. Updating a PlatformCapability component has the following semantic:

If the PlatformCapability object Class exists in the collection of PlatformCapability components, the existing PlatformCapability will be updated with the new PlatformCapability mappings. If the PlatformCapability object Class cannot be found, it will be added to the collection.

Updating a PlatformCapability component causes the state of this object to change, triggering the notification of all registered Observer instances

Parameters:
capability - The PlatformCapability to add
Throws:
Exception - If there are errors updating the PlatformCapability

removePlatformCapability

public boolean removePlatformCapability(PlatformCapability pCap,
                                        boolean clean)
Remove a PlatformCapability object. The removal of a PlatformCapability component causes the state of this object to change, triggering the notification of all registered Observer instances

Parameters:
pCap - The PlatformCapability to remove
clean - If this value is true and if the PlatformCapability has a DownloadRecord defined (was provisioned during the time this Cybernode was running) then remove the PlatformCapability from the system.
Returns:
True if removed, false otherwise

removalInProcess

public boolean removalInProcess(PlatformCapability pCap)
Determine if a PlatformCapability is being removed from the system. This will occur for provisioned PlatformCapability instances that are removed as a result of service termination.

Parameters:
pCap - The PlatformCapability to check
Returns:
True if the PlatformCapability is currently in the process of being removed

addMeasurableCapability

public boolean addMeasurableCapability(MeasurableCapability capability)
Add a MeasurableCapability object. The addition of a MeasurableCapability component causes the state of this object to change, triggering the notification of all registered Observer instances.

If there is a MeasurableCapability component that is equal to the provided MeasurableCapability (according to the MeasurableCapability.equals() contract), the existing MeasurableCapability object will be remain unchanged and the provided MeasurableCapability ignored

Parameters:
capability - The MeasurableCapability to add
Returns:
True if added, false otherwise

hasMeasurableCapability

public boolean hasMeasurableCapability(MeasurableCapability capability)
Determine if the MeasurableCapability exists in this ComputeResource

Parameters:
capability - The MeasurableCapability to check
Returns:
True if the MeasurableCapability exists, false otherwise

updateMeasurableCapability

public void updateMeasurableCapability(MeasurableCapability capability)
Update a MeasurableCapability object. Updating a MeasurableCapability component causes the state of this object to change, triggering the notification of all registered Observer instances.

If there is a MeasurableCapability object that is equal to the provided MeasurableCapability (according to the MeasurableCapability.equals() contract), the existing MeasurableCapability object will be replaced by the provided MeasurableCapability object

Parameters:
capability - The MeasurableCapability to update

removeMeasurableCapability

public boolean removeMeasurableCapability(MeasurableCapability capability)
Remove a MeasurableCapability object. The removal of a MeasurableCapability component causes the state of this object to change, triggering the notification of all registered Observer instances

Parameters:
capability - The MeasurableCapability to remove
Returns:
True if removed, false otherwise

stateChange

public void stateChange()
Notify all registered Observers the ComputeResource has changed. The argument provided on the Observable.notifyObservers() invocation will be the ResourceCapability component, used to communicate the resource utilization, platform and measurable capabilities attributes of the ComputeResource


addThresholdListener

public void addThresholdListener(ThresholdListener listener)
A helper method which will add a ThresholdListener to all contained MeasurableCapability components. An alternate mechanism is to obtain all MeasurableCapability components contained by the ComputeResource and add the listener to each component

Parameters:
listener - The ThresholdListener to add

removeThresholdListener

public void removeThresholdListener(ThresholdListener listener)
A helper method which will remove a ThresholdListener from all contained MeasurableCapability components. An alternate mechanism is to obtain all MeasurableCapability components contained by the ComputeResource and remove the listener from each component

Parameters:
listener - The ThresholdListener

getPlatformCapabilities

public PlatformCapability[] getPlatformCapabilities()
Return an array of PlatformCapability objects. This method will create a new array of PlatformCapability objects each time it is invoked. If there are no PlatformCapability objects contained within the platformCapabilities Collection, a zero-length array will be returned.

Returns:
Array of PlatformCapability objects

getPlatformCapability

public PlatformCapability getPlatformCapability(String name)
Get a PlatformCapability

Parameters:
name - The name of the PlatformCapability
Returns:
The first PlatformCapability that matches the name. If no PlatformCapability matches the name, return null
See Also:
PlatformCapability.NAME

getPlatformCapabilityNameTable

public Map<String,String> getPlatformCapabilityNameTable()
Get the PlatformCapability name table

Returns:
A Map of PlatformCapability names to PlatformCapability classnames. A new Map is created each time

getMeasurableCapability

public MeasurableCapability getMeasurableCapability(String description)
Get a MeasurableCapability

Parameters:
description - The description of the MeasurableCapability
Returns:
The first MeasurableCapability that matches the description. If no MeasurableCapability matches the description, return null

getMeasurableCapabilities

public MeasurableCapability[] getMeasurableCapabilities()
Return an array of MeasurableCapability objects. This method will create a new array of MeasurableCapability objects each time it is invoked. If there are no MeasurableCapability objects contained within the measurables Collection, a zero-length array will be returned.

Returns:
Array of MeasurableCapability objects

getMeasuredResources

public MeasuredResource[] getMeasuredResources()
Get the MeasuredResource components for the ComputeResource

Returns:
Array of MeasuredResource instances that correspond to MeasurableCapability components

getUtilization

public double getUtilization()
Get the resource utilization as computed by a summation of the MeasurableCapability components

Returns:
The aggregate utilization of the ComputeResource

setPersistentProvisioning

public void setPersistentProvisioning(boolean persistentProvisioning)
Set the persistentProvisioning property

Parameters:
persistentProvisioning - True if the ComputeResource supports persistent provisioning, false otherise

getPersistentProvisioning

public boolean getPersistentProvisioning()
Get the persistentProvisioning property

Returns:
True if the ComputeResource supports persistent provisioning, false otherwise

getPersistentProvisioningRoot

public String getPersistentProvisioningRoot()
Get the location for the persistent provisioning of PlatformCapability instances

Returns:
The root directory for the persistent provisioning of PlatformCapability instances

setPersistentProvisioningRoot

public void setPersistentProvisioningRoot(String provisionRoot)
Set the location for the persistent provisioning of PlatformCapability instances

Parameters:
provisionRoot - The root directory for the persistent provisioning of PlatformCapability instances

getResourceCapability

public ResourceCapability getResourceCapability()
Return the ResourceCapabilityobject that will be used to communicate the platform and measurable capabilities attributes of the ComputeResource

Returns:
The ResourceCapability object for the ComputeResource

getComputeResourceUtilization

public ComputeResourceUtilization getComputeResourceUtilization()
Get the ComputeResourceUtilization

Returns:
A ComputeResourceUtilization object representing the utilization of the ComputeResource

boot

public void boot()
Boot the ComputeResource, loading all PlatformCapability and MeasurableCapability instances


shutdown

public void shutdown()
Inform all MeasurableCapability instances to stop measuring


Copyright © Rio Project.

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