org.gridlab.gat.resources
Class ResourceDescription

java.lang.Object
  extended by org.gridlab.gat.resources.ResourceDescription
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HardwareResourceDescription, SoftwareResourceDescription

public abstract class ResourceDescription
extends Object
implements Serializable

The ResourceDescription interface forms the base for the SoftwareResourceDescriptions and HardwareResourceDescriptions classes; these are used to specify and find resources which may then be used, for example, to submit a Job to. It has an associated Map whose key/value pairs describe the resource.

A Job may have many requirements, both on software and hardware, which need to be satisfied to run, e.g. specific versions of the operating system, minimum amount of memory, presence of specific compilers or libraries on a system, etc. Each one of these requirements may itself possibly in turn depend on some other software or hardware requirement. Sometimes there may be possible alternatives, for example the Job may be able to use any one of a set of possible system libraries which might be installed. Hence, a complete ResourceDescription requires a list of possible specifications, and, ideally, some way of specifying allowable alternatives. In order to accommodate this, a ResourceDescription has, as well as a table describing software of hardware resource requirements, a list of child ResourceDescriptions, at least one of which must be satisfied in addition to the requirements of this ResourceDescription.

Thus, a ResourceDescription is a tree, and it is matched if a path exists from the root of the tree to any leaf where the requirements of every node on that path are met.

Author:
rob
See Also:
Serialized Form

Method Summary
 void addResourceAttribute(String name, Object value)
          Adds the name/value pair to the Map<String, Object> of name/value pairs which describe this Resource.
 void addResourceDescription(ResourceDescription hardwareResourceDescription)
          Adds the passed HardwareResourceDescription to the List of HardwareResourceDescriptions which describe this Resource.
 boolean equals(Object object)
          Tests this ResourceDescription for equality with the passed Object.
 Map<String,Object> getDescription()
          Gets the attributes associated with this instance
 Object getResourceAttribute(String name)
          Returns an attribute of this description given the key.
 int hashCode()
           
 void removeResourceAttribute(String name)
          Removes the name/value pair with the passed name from the Map<String, Object> of name/value pairs which describe this Resource.
 void removeResourceDescription(ResourceDescription hardwareResourceDescription)
          Removes the passed HardwareResourceDescription from the List of HardwareResourceDescriptions which describe this Resource.
 void setDescription(Map<String,Object> attributes)
          Sets the attributes associated with this instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

equals

public boolean equals(Object object)
Tests this ResourceDescription for equality with the passed Object.

If the given object is not a SoftwareResourceDescription, then this method immediately returns false.

If the passed object is a SoftwareResourceDescription, then it is equal if it has an equivalent SoftwareResourceDescription, and an equivalent SoftwareResourceDescriptions, and an equivalent HardwareResourceDescriptions.

Overrides:
equals in class Object
Parameters:
object - The Object to test for equality
Returns:
A boolean indicating equality

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getDescription

public Map<String,Object> getDescription()
Gets the attributes associated with this instance

Returns:
A Map<String, Object>, the SoftwareResourceDescription associated with this instance

setDescription

public void setDescription(Map<String,Object> attributes)
Sets the attributes associated with this instance. Overwrites any earlier attributes.

Parameters:
attributes - The new Map<String, Object>, the SoftwareResourceDescription associated with this instance

addResourceAttribute

public void addResourceAttribute(String name,
                                 Object value)
Adds the name/value pair to the Map<String, Object> of name/value pairs which describe this Resource.

Parameters:
name - the key, a String, to add to the name/value pairs which describe this Resource.
value - the value, an Object, to add to the name/value pairs which describes this Resource.

getResourceAttribute

public Object getResourceAttribute(String name)
Returns an attribute of this description given the key.

Parameters:
name - the name of the attribute
Returns:
the attribute value, or null if the key is not present

removeResourceAttribute

public void removeResourceAttribute(String name)
Removes the name/value pair with the passed name from the Map<String, Object> of name/value pairs which describe this Resource.

Parameters:
name - The key, a String, to of the name/value pair to remove from the name/value pairs which describe this Resource.

addResourceDescription

public void addResourceDescription(ResourceDescription hardwareResourceDescription)
Adds the passed HardwareResourceDescription to the List of HardwareResourceDescriptions which describe this Resource.

Parameters:
hardwareResourceDescription - The HardwareResourceDescription to add to the List of HardwareResourceDescriptions which describe this Resource.

removeResourceDescription

public void removeResourceDescription(ResourceDescription hardwareResourceDescription)
                               throws NoSuchElementException
Removes the passed HardwareResourceDescription from the List of HardwareResourceDescriptions which describe this Resource.

Parameters:
hardwareResourceDescription - The HardwareResourceDescription to remove from the List of HardwareResourceDescriptions which describe this Resource.
Throws:
NoSuchElementException - the element to be removed cannot be found

toString

public String toString()
Overrides:
toString in class Object