edu.isi.pegasus.planner.partitioner
Class Partition

java.lang.Object
  extended by edu.isi.pegasus.planner.classes.Data
      extended by edu.isi.pegasus.planner.partitioner.Partition
All Implemented Interfaces:
Cloneable

public class Partition
extends Data

This is an abstract container for a partition in the graph. This used for the generation of the partition element in the partition graph, and identifies the relations between the jobs in the partition if any.

Version:
$Revision: 2753 $
Author:
Karan Vahi

Field Summary
private  String mID
          The partition id of the partition.
private  int mIndex
          The index associated with the partition.
private  GraphNode mLastAddedNode
          A pointer to the last added node to the partition.
private  String mName
          The name of the partition.
private  List mNodeList
          The list of GraphNode objects corresponding to the nodes making the partiition.
private  Set mNodeSet
          The set of node id's in the partition.
private  Map mParentsMap
          A map containing a node and it's parents ids in the partition.
 
Fields inherited from class edu.isi.pegasus.planner.classes.Data
mLogger, mLogMsg
 
Constructor Summary
Partition()
          The default constructor.
Partition(List nodeList, String id)
          The overloaded constructor.
 
Method Summary
 void addNode(GraphNode node)
          Adds a node to the partition.
 void addParents(String node, List parents)
          Ends up assigning the parents to a particular node.
 Object clone()
          Returns a copy of the object
 void constructPartition()
          It while looking at the node list constructs the relations between the jobs in the partition, that can be gotten through getRelationsInPartition().
 String getID()
          It returns the unique id that is associated with the partition.
 int getIndex()
          It returns the index to number of the partition.
 String getName()
          It returns the name of the partition.
 Set getNodeIDs()
          It returns the set of the job ids making up the partition.
 List getNodes()
          Returns a list of nodes making up the partition.
 Map getRelations()
          A function to return the child-parent relations for the jobs making up the partition.
 List getRootNodes()
          Returns the root nodes in the partition.
 GraphNode lastAddedNode()
          Returns the last added node to the partition.
 void setID(String id)
          It sets the id of the partition.
 void setIndex(int index)
          It sets the index associated with this partition to the value passed.
 void setName(String name)
          It sets the partition name to the value passed.
 int size()
          Returns the number of nodes in the partition.
 String toString()
          Returns a String version of the object.
 String toXML()
          Returns the xml description of the object.
 void toXML(Writer writer)
          Returns the xml description of the object.
private  void writeAttribute(Writer writer, String key, String value)
          Writes an attribute to the stream.
 
Methods inherited from class edu.isi.pegasus.planner.classes.Data
setToString, vectorToString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mNodeSet

private Set mNodeSet
The set of node id's in the partition.


mParentsMap

private Map mParentsMap
A map containing a node and it's parents ids in the partition. A node id's is the key and the corresponding value is the list of String id's of it's parents. The map only contain those nodes for which there is a parent.


mNodeList

private List mNodeList
The list of GraphNode objects corresponding to the nodes making the partiition.


mID

private String mID
The partition id of the partition.


mIndex

private int mIndex
The index associated with the partition. In most cases the ID of the partition is constructed using this index.


mName

private String mName
The name of the partition.


mLastAddedNode

private GraphNode mLastAddedNode
A pointer to the last added node to the partition.

Constructor Detail

Partition

public Partition()
The default constructor.


Partition

public Partition(List nodeList,
                 String id)
The overloaded constructor.

Parameters:
nodeList - list of GraphNode objects.
id - the partition id of the partition.
Method Detail

addNode

public void addNode(GraphNode node)
Adds a node to the partition. It ends up adding it to the underneath node list.

Parameters:
node - the GraphNode object corresponding to the job that is to be added.

lastAddedNode

public GraphNode lastAddedNode()
Returns the last added node to the partition.

Returns:
the last added node, or null in case partition is empty

getNodes

public List getNodes()
Returns a list of nodes making up the partition.

Returns:
List of GraphNode objects.

getRootNodes

public List getRootNodes()
Returns the root nodes in the partition. They can only be determined, after the constructPartition() has been called.

Returns:
List of GraphNode objects that are the root.

constructPartition

public void constructPartition()
It while looking at the node list constructs the relations between the jobs in the partition, that can be gotten through getRelationsInPartition().


setName

public void setName(String name)
It sets the partition name to the value passed.

Parameters:
name - the name to which the partition name needs to be set to.

getName

public String getName()
It returns the name of the partition.


setIndex

public void setIndex(int index)
It sets the index associated with this partition to the value passed.

Parameters:
index - the index value.

getIndex

public int getIndex()
It returns the index to number of the partition.


getID

public String getID()
It returns the unique id that is associated with the partition.


setID

public void setID(String id)
It sets the id of the partition.

Parameters:
id - the id of the partition.

size

public int size()
Returns the number of nodes in the partition.

Returns:
the number of nodes.

toString

public String toString()
Returns a String version of the object.

Specified by:
toString in class Data

toXML

public void toXML(Writer writer)
           throws IOException
Returns the xml description of the object. This is used for generating the partition graph. That is no longer done.

Parameters:
writer - is a Writer opened and ready for writing. This can also be a StringWriter for efficient output.
Throws:
IOException - if something fishy happens to the stream.

toXML

public String toXML()
             throws IOException
Returns the xml description of the object. This is used for generating the partition graph. That is no longer done.

Returns:
String containing the Partition object in XML.
Throws:
IOException - if something fishy happens to the stream.

writeAttribute

private void writeAttribute(Writer writer,
                            String key,
                            String value)
                     throws IOException
Writes an attribute to the stream. Wraps the value in quotes as required by XML.

Parameters:
writer -
key -
value -
Throws:
IOException - if something fishy happens to the stream.

getNodeIDs

public Set getNodeIDs()
It returns the set of the job ids making up the partition.


addParents

public void addParents(String node,
                       List parents)
Ends up assigning the parents to a particular node. It does assign the parents to the node, if the node is in the partition. It however does not check if the parents are in the partition or not.

Parameters:
node - the id of the node for which you want to add the parents.
parents - list of id's of the parents of the nodes.

getRelations

public Map getRelations()
A function to return the child-parent relations for the jobs making up the partition. The child parent relations are only returned for the jobs that have parents in the partition.

Returns:
Map containing the job id's as the keys and the values as the list of the parent id's in the partition.

clone

public Object clone()
             throws CloneNotSupportedException
Returns a copy of the object

Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2011 The University of Southern California. All Rights Reserved.