org.griphyn.vdl.dax
Class ADAG

java.lang.Object
  extended by org.griphyn.vdl.Chimera
      extended by org.griphyn.vdl.dax.DAX
          extended by org.griphyn.vdl.dax.ADAG
All Implemented Interfaces:
Cloneable

public class ADAG
extends DAX
implements Cloneable

This class is the container for an abstract DAG description. It consists of three parts.

  1. Filename deals with the filenames that are used in the picture of the DAG - does a file go into the DAG, come out of the DAG, or is it an intermediary file. There are multiple instances stored in a DAX.
  2. Job deals with the description of all jobs in a DAG. Each job has a logical transformation, commandline argument, possible stdio redirection, and a potential set of Profile settings. There are multiple instance stored in a DAX.
  3. Child deals with the dependency in a two-level fashion. It contains a list of child to parent(s) relationships. The children and parents refer to jobs from the previous section. There are multiple instances stored in a DAX.

Version:
$Revision: 366 $
Author:
Jens-S. V??ckler, Yong Zhao

Field Summary
private  TreeMap m_childMap
          list of all child nodes to construct DAG.
private  boolean m_dirty
           
private  TreeMap m_fileMap
          list of all filenames in terms of Filename
private  int m_index
          When generating alternatives, this is the zero-based count.
private  TreeMap m_jobMap
          list of all jobs
private  String m_name
          optional name of this document.
private  TreeMap m_replace
          list of replacements for node collapsion from compounds.
private  int m_size
          When generating alternatives, this is the total number of alternatives.
private  String m_version
          The version to report back, or alternatively to the version that the DAX file had when reading.
static String SCHEMA_LOCATION
          The "not-so-official" location URL of the DAX schema definition.
static String SCHEMA_NAMESPACE
          The "official" namespace URI of the DAX schema.
static String SCHEMA_VERSION
          The version to report.
 
Constructor Summary
ADAG()
          Default ctor: construct a hollow shell to add data later.
ADAG(int size, int index)
          Ctor: Construct a hollow shell with the required arguments.
ADAG(int size, int index, String name)
          Ctor: Construct a hollow shell with all element attributes
 
Method Summary
 boolean addChild(Child child)
          Adds a child node which was constructed elsewhere to the list of known children.
 boolean addChild(String child_id)
          Adds a child node without any parent relationship to the list of known children.
 boolean addChild(String child_id, String parent_id)
          Adds a child node with a parent relationship to the list of known children.
protected  boolean addFilename(Filename lfn)
          Adds a completely constructed Filename structure to the map of filenames.
 void addFilename(String lfn, boolean isInput, String temporary, boolean dontRegister, int dontTransfer)
          Adds a logical filename string with input or output notion to the list of maintained filenames.
 boolean addJob(Job job)
          Adds a completely constructed Job structure to the map of jobs.
 int adjustLevels(String id, int distance)
          Adjusts all job levels along the search path.
 Object clone()
          Creates and returns a copy of this object.
 Enumeration enumerateChild()
          Deprecated. Use the new Collection based interfaces
 Enumeration enumerateFilename()
          Deprecated. Use the new Collection based interfaces
 Enumeration enumerateJob()
          Deprecated. Use the new Collection based interfaces
 int getChildCount()
          Access: Counts the number of dependencies in the DAG.
 Filename getFilename(String lfn)
          Accessor: Obtains a Filename from its string.
 int getFilenameCount()
          Accessor: Obtains the index of filename instances.
 int getIndex()
          Accessor: Obtains the zero-based index.
 Job getJob(String jobID)
          Accessor: Obtains a job by its id from the job list.
 int getJobCount()
          Accessor: Counts the number of jobs in the abstract DAG.
 String getName()
          Accessor: Obtains the name of the DAX.
 int getSize()
          Accessor: Obtains the total number of alternatives.
 String getVersion()
          Accessor: Obtains the version that will be reported in the DAX.
 Iterator iterateChild()
          Accessor: Provides an iterator for the bag of relationships.
 Iterator iterateFilename()
          Accessor: Provides an iterator for the bag of filenames.
 Iterator iterateJob()
          Accessor: Provides an iterator for the bag of jobs.
 void removeAllFilename()
          Accessor: Removes all filename instances.
 Filename removeFilename(String lfn)
          Accessor: Removes a specific logical filename instance from the bag.
 String replaceParent(String oldid, String newid)
          Registers a job node collapsion as a replacement.
 void setFilename(Collection files)
          Accessor: Replace this filename instance list with a new list.
 void setFilename(Filename vFilename)
          Accessor: Overwrites an filename instance with a new one.
 void setFilename(Filename[] fileArray)
          Deprecated. Use the new Collection based interfaces
 void setFilename(Map files)
          Accessor: Replace this filename instance list with a map.
 void setIndex(int index)
          Acessor: Sets a new zero-based index for this document.
 void setName(String name)
          Acessor: Sets a new optional name for this document.
 void setSize(int size)
          Acessor: Sets a new total document count in this document.
 void setVersion(String version)
          Acessor: Sets a new version number for this document.
 void toString(Writer stream)
          Converts the active state into something meant for human consumption.
 void toXML(Writer stream, String indent, String namespace)
          Dump the state of the current element as XML output.
private  void updateChildren()
           
 void writeXMLHeader(Writer stream, String indent, String namespace)
          Writes the header of the XML output.
 
Methods inherited from class org.griphyn.vdl.Chimera
escape, quote, toString, toXML, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCHEMA_NAMESPACE

public static final String SCHEMA_NAMESPACE
The "official" namespace URI of the DAX schema.

See Also:
Constant Field Values

SCHEMA_LOCATION

public static final String SCHEMA_LOCATION
The "not-so-official" location URL of the DAX schema definition.

See Also:
Constant Field Values

SCHEMA_VERSION

public static final String SCHEMA_VERSION
The version to report.

See Also:
Constant Field Values

m_fileMap

private TreeMap m_fileMap
list of all filenames in terms of Filename

See Also:
Filename

m_jobMap

private TreeMap m_jobMap
list of all jobs

See Also:
Job

m_childMap

private TreeMap m_childMap
list of all child nodes to construct DAG.

See Also:
Child

m_replace

private TreeMap m_replace
list of replacements for node collapsion from compounds.


m_dirty

private boolean m_dirty

m_name

private String m_name
optional name of this document.


m_size

private int m_size
When generating alternatives, this is the total number of alternatives.


m_index

private int m_index
When generating alternatives, this is the zero-based count.


m_version

private String m_version
The version to report back, or alternatively to the version that the DAX file had when reading.

Constructor Detail

ADAG

public ADAG()
Default ctor: construct a hollow shell to add data later.


ADAG

public ADAG(int size,
            int index)
Ctor: Construct a hollow shell with the required arguments.

Parameters:
size - is the total number of DAXes that will be constructed.
index - is the zero-based number in the total number of DAXes.

ADAG

public ADAG(int size,
            int index,
            String name)
Ctor: Construct a hollow shell with all element attributes

Parameters:
size - is the total number of DAXes that will be constructed.
index - is the zero-based number in the total number of DAXes.
name - is an optional name to use for the DAX. In later versions this might be useful, if several DAXes are interleaved on the same connection.
Method Detail

clone

public Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class Object
Returns:
a new instance, deep copy of elements

addFilename

public void addFilename(String lfn,
                        boolean isInput,
                        String temporary,
                        boolean dontRegister,
                        int dontTransfer)
Adds a logical filename string with input or output notion to the list of maintained filenames. If the filename does not exist previously, a new entry is added. If the filename does exist, the io state will be checked. A filename that was previously an input, and is now an output, will become inout. If a filename was ever declared not-transfer or not-register, it will maintain these attributes. Each filename is only added once.

Parameters:
lfn - is the logical filename string
isInput - is a predicate with true to signal an input filename.
temporary - is a temp file hint, currently unused.
dontRegister - a true value will be propagated (mono-flop)
dontTransfer - any non-mandatory value will be propagated

addFilename

protected boolean addFilename(Filename lfn)
Adds a completely constructed Filename structure to the map of filenames. The structure must be assembled outside. This method is primarily a convenience for the clone() method.

Parameters:
lfn - is the Filename instance.
Returns:
true, if the bag did not contain an identical Filename already.

addJob

public boolean addJob(Job job)
Adds a completely constructed Job structure to the map of jobs. The structure must be assembled outside, using the related classes. The job ID will be taken as unique key. If a job with this ID already exists in the DAX, it will be replaced with the new job.

Parameters:
job - is the new job to add
Returns:
true, if the bag did not contain this job already.

addChild

public boolean addChild(Child child)
Adds a child node which was constructed elsewhere to the list of known children. If the child already exists, nothing is done.

Parameters:
child - is the new Child instance to put into the bag.
Returns:
true if the bag did not already contain the specified element.

addChild

public boolean addChild(String child_id)
Adds a child node without any parent relationship to the list of known children. If the child already exists, nothing is done.

Parameters:
child_id - is the new child to put into the bag.
Returns:
true if the bag did not already contain the specified element.

addChild

public boolean addChild(String child_id,
                        String parent_id)
Adds a child node with a parent relationship to the list of known children. If the child already exists, but the parent relationship is not known, it will be added to the child's list of parents. If the child already exists and the parent relationship is known, nothing is done.

Parameters:
child_id - is the id of the child for which to modify a parent
parent_id - is the new parent to add to the specified child.
Returns:
true if the bag did not already contain the relationship.

replaceParent

public String replaceParent(String oldid,
                            String newid)
Registers a job node collapsion as a replacement.


enumerateFilename

public Enumeration enumerateFilename()
Deprecated. Use the new Collection based interfaces

Accessor: Provides an iterator for the bag of filenames.

Returns:
the iterator for Filename elements.
See Also:
Filename

enumerateJob

public Enumeration enumerateJob()
Deprecated. Use the new Collection based interfaces

Accessor: Provides an iterator for the bag of jobs.

Returns:
the iterator for Job elements.
See Also:
Job

enumerateChild

public Enumeration enumerateChild()
Deprecated. Use the new Collection based interfaces

Accessor: Provides an iterator for the bag of relationships.

Returns:
the iterator for Child elements.
See Also:
Child

getFilename

public Filename getFilename(String lfn)
Accessor: Obtains a Filename from its string.

Parameters:
lfn - is the logical filename string to look it up with.
Returns:
the filename instance at the specified place.
See Also:
addFilename( Filename ), setFilename( Filename )

getFilenameCount

public int getFilenameCount()
Accessor: Obtains the index of filename instances.

Returns:
the number of arguments in the filename list.
See Also:
Filename

getJobCount

public int getJobCount()
Accessor: Counts the number of jobs in the abstract DAG.

Returns:
the number of jobs.

getChildCount

public int getChildCount()
Access: Counts the number of dependencies in the DAG.

Returns:
dependency count, which may be zilch.

getIndex

public int getIndex()
Accessor: Obtains the zero-based index.

Returns:
a number in the interval [0,size-1].
See Also:
setIndex( int )

getJob

public Job getJob(String jobID)
Accessor: Obtains a job by its id from the job list.

Returns:
a job or null, if not found.
See Also:
addJob( Job )

getName

public String getName()
Accessor: Obtains the name of the DAX.

Returns:
the name of this DAX, or null, if no name was specified.
See Also:
setName( String )

getSize

public int getSize()
Accessor: Obtains the total number of alternatives. This is the number of DAXes generatable from alternatives.

Returns:
a positive natural integer.
See Also:
setSize( int )

getVersion

public String getVersion()
Accessor: Obtains the version that will be reported in the DAX.

Returns:
the version as a string.
Since:
1.7
See Also:
setVersion( String )

iterateFilename

public Iterator iterateFilename()
Accessor: Provides an iterator for the bag of filenames.

Returns:
the iterator for Filename elements.
See Also:
Filename

iterateJob

public Iterator iterateJob()
Accessor: Provides an iterator for the bag of jobs.

Returns:
the iterator for Job elements.
See Also:
Job

iterateChild

public Iterator iterateChild()
Accessor: Provides an iterator for the bag of relationships.

Returns:
the iterator for Child elements.
See Also:
Child

removeAllFilename

public void removeAllFilename()
Accessor: Removes all filename instances.

See Also:
Filename

removeFilename

public Filename removeFilename(String lfn)
Accessor: Removes a specific logical filename instance from the bag.

Parameters:
lfn - is the logical filename string to refer to a filename.
Returns:
the Filename instance to which this lfn had been mapped in this hashtable, or null if the lfn did not have a mapping.

setFilename

public void setFilename(Filename vFilename)
Accessor: Overwrites an filename instance with a new one.

Parameters:
vFilename - is the new filename instance, which contains all necessary information.

setFilename

public void setFilename(Filename[] fileArray)
Deprecated. Use the new Collection based interfaces

Accessor: Replace this filename instance list with a new list.

Parameters:
fileArray - is the new list of Filename instances
See Also:
Filename

setFilename

public void setFilename(Collection files)
Accessor: Replace this filename instance list with a new list.

Parameters:
files - is the new collection of Filename instances
See Also:
Filename

setFilename

public void setFilename(Map files)
Accessor: Replace this filename instance list with a map.

Parameters:
files - is the new map of Filename instances
See Also:
Filename

setIndex

public void setIndex(int index)
Acessor: Sets a new zero-based index for this document. The index is used in conjunction with the total number of documents count.

Parameters:
index - is the new zero-based index of this element.
See Also:
getIndex()

setName

public void setName(String name)
Acessor: Sets a new optional name for this document.

Parameters:
name - is the new name.
See Also:
getName()

setSize

public void setSize(int size)
Acessor: Sets a new total document count in this document. The count is used in conjunction with the zero-based document index.

Parameters:
size - is the new total document count.
See Also:
getSize()

setVersion

public void setVersion(String version)
Acessor: Sets a new version number for this document. The version number is taken by the abstract planner to support a range of valid DAX documents.

Parameters:
version - is the new version number as string composed of two integers separted by a period.
Since:
1.7
See Also:
getVersion()

updateChildren

private void updateChildren()

adjustLevels

public int adjustLevels(String id,
                        int distance)
Adjusts all job levels along the search path. Given a starting point, this method will re-iterate the search-tree, and adjust the level of each known job by the specified distance.

Parameters:
id - is the job id to start
distance - is the increment (or decrement for negative).
Returns:
number of jobs adjusted?

toString

public void toString(Writer stream)
              throws IOException
Converts the active state into something meant for human consumption. The method will be called when recursively traversing the instance tree.

Specified by:
toString in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
Throws:
IOException - if something fishy happens to the stream.

writeXMLHeader

public void writeXMLHeader(Writer stream,
                           String indent,
                           String namespace)
                    throws IOException
Writes the header of the XML output. The output contains the special strings to start an XML document, some comments, and the root element. The latter points to the XML schema via XML Instances.

Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Throws:
IOException - if something fishy happens to the stream.

toXML

public void toXML(Writer stream,
                  String indent,
                  String namespace)
           throws IOException
Dump the state of the current element as XML output. This function traverses all sibling classes as necessary, and converts the data into pretty-printed XML output. The stream interface should be able to handle large output efficiently.

Specified by:
toXML in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Throws:
IOException - if something fishy happens to the stream.
See Also:
BufferedWriter


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