edu.isi.pegasus.planner.partitioner
Class WriterCallback

java.lang.Object
  extended by edu.isi.pegasus.planner.partitioner.WriterCallback
All Implemented Interfaces:
Callback

public class WriterCallback
extends Object
implements Callback

This callback writes out a DAX file for each of the partitions, and also writes out a PDAX file that captures the relations between the partitions.

Version:
$Revision: 2576 $
Author:
not attributable

Field Summary
protected  DAXWriter mDAXWriter
          The handle to the dax writer that writes out the dax corresponding to the partition identified.
protected  LogManager mLogger
          The handle to the logger object.
protected  boolean mPartitioningStarted
          A boolean indicating that the partitioning has started.
protected  String mPDAX
          The path to the PDAX file written out.
protected  PDAXWriter mPDAXWriter
          The handle to the partition graph writer.
protected  PegasusProperties mProps
          Handle to the properties available.
 
Constructor Summary
WriterCallback()
          The default constructor.
 
Method Summary
 void cbDone()
          Callback for the partitioner to signal that it is done with the processing.
 void cbParents(String child, List parents)
          Callback for when a partitioner determines the relations between partitions that it has previously constructed.
 void cbPartition(Partition p)
          Callback for when a partitioner determines that partition has been constructed.
protected  PDAXWriter getHandletoPDAXWriter(String daxFile, String name, String directory)
          It returns the handle to the writer for writing out the pdax file that contains the relations amongst the partitions and the jobs making up the partitions.
protected  String getPartitionName()
          Returns the name of the partition, that needs to be set while creating the Partition object corresponding to each partition.
 String getPDAX()
          Returns the name of the pdax file written out.
 void initialize(PegasusProperties properties, String daxFile, String daxName, String directory)
          Initializes the Writer Callback.
protected  String partitionRelation2XML(String childID, List parentIDs)
          Returns the xml description of a relation between 2 partitions.
protected  String partitionRelation2XML(String childID, Set parentIDs)
          Returns the xml description of a relation between 2 partitions.
protected  String partitionRelation2XML(String childID, String parentID)
          Returns the xml description of a relation between 2 partitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mPDAXWriter

protected PDAXWriter mPDAXWriter
The handle to the partition graph writer.


mDAXWriter

protected DAXWriter mDAXWriter
The handle to the dax writer that writes out the dax corresponding to the partition identified. The base name of the partition is gotten from it.


mPDAX

protected String mPDAX
The path to the PDAX file written out.


mProps

protected PegasusProperties mProps
Handle to the properties available.


mLogger

protected LogManager mLogger
The handle to the logger object.


mPartitioningStarted

protected boolean mPartitioningStarted
A boolean indicating that the partitioning has started. This is set, by the first call to the cbPartition( Partition ) callback.

Constructor Detail

WriterCallback

public WriterCallback()
The default constructor.

Method Detail

initialize

public void initialize(PegasusProperties properties,
                       String daxFile,
                       String daxName,
                       String directory)
Initializes the Writer Callback.

Parameters:
properties - the properties passed to the planner.
daxFile - the path to the DAX file that is being partitioned.
daxName - the namelabel of the DAX as set in the root element of the DAX.
directory - the directory where the partitioned daxes have to reside.

cbPartition

public void cbPartition(Partition p)
Callback for when a partitioner determines that partition has been constructed. A DAX file is written out for the partition.

Specified by:
cbPartition in interface Callback
Parameters:
p - the constructed partition.
Throws:
RuntimeException - in case of any error while writing out the DAX or the PDAX files.

cbParents

public void cbParents(String child,
                      List parents)
Callback for when a partitioner determines the relations between partitions that it has previously constructed.

Specified by:
cbParents in interface Callback
Parameters:
child - the id of a partition.
parents - the list of String objects that contain the id's of the parents of the partition.
Throws:
RuntimeException - in case of any error while writing out the DAX or the PDAX files.

cbDone

public void cbDone()
Callback for the partitioner to signal that it is done with the processing. This internally closes all the handles to the DAX and PDAX writers.

Specified by:
cbDone in interface Callback

getPDAX

public String getPDAX()
Returns the name of the pdax file written out. Will be null if the partitioning has not completed.

Returns:
path to the pdax file.

getPartitionName

protected String getPartitionName()
Returns the name of the partition, that needs to be set while creating the Partition object corresponding to each partition.

Returns:
the name of the partition.

getHandletoPDAXWriter

protected PDAXWriter getHandletoPDAXWriter(String daxFile,
                                           String name,
                                           String directory)
It returns the handle to the writer for writing out the pdax file that contains the relations amongst the partitions and the jobs making up the partitions.

Parameters:
daxFile - the path to the DAX file that is being partitioned.
name - the name/label that is to be assigned to the pdax file.
directory - the directory where the partitioned daxes have to reside.
Returns:
handle to the writer of pdax file.

partitionRelation2XML

protected String partitionRelation2XML(String childID,
                                       String parentID)
Returns the xml description of a relation between 2 partitions.

Parameters:
childID - the ID of the child.
parentID - the ID of the parent.
Returns:
the XML description of child parent relation.

partitionRelation2XML

protected String partitionRelation2XML(String childID,
                                       List parentIDs)
Returns the xml description of a relation between 2 partitions.

Parameters:
childID - the ID of the child
parentIDs - List of parent IDs.
Returns:
the XML description of child parent relations.

partitionRelation2XML

protected String partitionRelation2XML(String childID,
                                       Set parentIDs)
Returns the xml description of a relation between 2 partitions.

Parameters:
childID - the ID of the child
parentIDs - Set of parent IDs.
Returns:
the XML description of child parent relations.


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