edu.isi.pegasus.planner.parser.dax
Class DAXParser2

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.isi.pegasus.planner.parser.Parser
          extended by edu.isi.pegasus.planner.parser.dax.DAXParser2
All Implemented Interfaces:
DAXParser, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class DAXParser2
extends Parser
implements DAXParser

This class parses the XML file whichis generated by Abstract Planner and ends up making an ADag object which contains theinformation to make the Condor submit files. The parser used to parse the file is Xerces.

Version:
$Revision: 4559 $
Author:
Karan Vahi, Gaurang Mehta
See Also:
org.griphyn.cPlanner.classes.Job, org.griphyn.cPlanner.classes.DagInfo, org.griphyn.cPlanner.classes.ADag, org.griphyn.cPlanner.classes.PCRelation

Field Summary
private static String DAX_VERSION_WITHOUT_DOUBLE_NEGATIVE
          The constant designating the version when the double negative transfer and registration flags were removed.
private  boolean infoAboutAllFilesRecv
          A boolean variable set to true when we have got all the logical filenames.
private  boolean mArgumentTag
           
private  Callback mCallback
          The handle to the class implementing the callback interface.
private  String mCurrentChildId
          These store the current child element for the child parent relationship.
private  Job mCurrentJobSubInfo
          Holds information regarding the current job being parsed.
private  String mDAGLFN
          The file attribute encountered in the dag element.
private  String mDAXLFN
          The file attribute encountered in the dax element.
 String mDaxSchemaVersion
           
private static Map<String,String> mExecutionToHintsNamespace
          The map that maps keys in execution tag to hints namespace.
protected  String mJobPrefix
          The job prefix that needs to be applied to the job file basenames.
private  String mNamespace
          For holding the namespace if specified in the Profile Element.
private  List<PCRelation> mParents
          The list of parents of a node referred to by mCurrentChildId.
private  String mProfileKey
          For holding the key attribute in profile tag.
private  boolean mProfileTag
          Set as and when Profile and Argument tags are started and ended.
private  boolean mUseDoubleNegative
          A boolean indicating whether to use the double negative flags for transfer and register or not.
private  String mUsesLinkType
          The uses link type for a file when uses tag is parsed.
private  PegasusFile mUsesPegasusFile
          The PegasusFile object that a uses tag corresponds to.
private  Set mVJobInpFiles
          Holds the input files for a particular job making the aDag.
private  Set mVJobOutFiles
          Holds the output files for a particular job making the aDag.
private  String mWholeCommandString
          All the arguments to a particular job.
static String SCHEMA_LOCATION
          The "not-so-official" location URL of the DAX schema definition.
static String SCHEMA_NAMESPACE
          URI namespace
 
Fields inherited from class edu.isi.pegasus.planner.parser.Parser
DEFAULT_PARSER_NAME, mAdjFName, mLocator, mLogger, mLogMsg, mParser, mProps, mTextContent, mTextString
 
Constructor Summary
DAXParser2(PegasusBag bag)
          The default constructor
 
Method Summary
private  TransformationCatalogEntry constructTCEntryFromJobHints(Job job)
          Constructs a TC entry object from the contents of a job.
 void endDocument()
          Here we have all the elements in our data structure.
 void endElement(String uri, String localName, String qName)
          Overrides the default implementation when the elements end tag comes.
private static String executionToHintsNamespace(String key)
          Maps the execution key to corresponding key in hints namespace.
 String extractVersionFromSchema(String schema)
          Determines the version of the DAX as specified in a schema string.
 Callback getDAXCallback()
          Retuns the DAXCallback for the parser
 String getSchemaLocation()
          Helps the load database to locate the DAX XML schema, if available.
 String getSchemaNamespace()
          Returns the XML schema namespace that a document being parsed conforms to.
 String getSchemaOfDocument(String file)
          A convenience method that tries to get the name of the schema the document refers to.
 String getVersionOfDAX(String file)
          A convenience method that tries to determine the version of the dax schema by reading ahead in the DAX file, and searching for the version attribue in the file.
private  void handleAdagTagStart(String local, Attributes attrs)
          Invoked when the starting of the adag element is got.
private  void handleArgumentTagEnd()
          Invoked when the end of the Argument Tag is reached.
private  void handleArgumentTagStart(String local, Attributes attrs)
          Invoked when the starting of the Argument Tag is reached.
private  void handleChildTagEnd()
          This passes the child and it's parents list to the callback object.
private  void handleChildTagStart(String local, Attributes attrs)
          Invoked when the starting of the child element is got.
private  void handleDAGTagEnd()
          Invoked when the end of the dag tag is reached.
private  void handleDAGTagStart(String local, Attributes attrs)
          Invoked when the starting of the dax element is retrieved.
private  void handleDAXTagEnd()
          Invoked when the end of the job tag is reached.
private  void handleDAXTagStart(String local, Attributes attrs)
          Invoked when the starting of the dax element is retrieved.
private  void handleExecutionTagEnd()
          Invoked when the end of the execution element is reached.
private  void handleExecutionTagStart(String local, Attributes attrs)
          Replaces the keys associated with the execution tag, with the corresponding keys in the hints profile namespace
private  void handleFilenameTagStart(String local, Attributes attrs)
          Invoked when the starting of the filename element is got.
private  void handleJobTagEnd()
          Invoked when the end of the job tag is reached.
private  void handleJobTagStart(Job job)
          Invoked when the starting of the job element is got.
private  void handleJobTagStart(String local, Attributes attrs)
          Invoked when the starting of the job element is got.
private  void handleMetadataTagEnd()
          Resets the text content buffer
private  void handleMetadataTagStart(String local, Attributes attrs)
          Metadata parsing is ignored for time being.
private  void handleParentTagStart(String local, Attributes attrs)
          Invoked when the starting of the parent element is got.
private  void handleProfileTagEnd()
          Invoked when the end of the profile element is got.
private  void handleProfileTagStart(String local, Attributes attrs)
          Invoked when the starting of the profile element is got.
private  void handleStderrTagStart(String local, Attributes attrs)
          Invoked when the starting of the stdout tag is reached.
private  void handleStdinTagStart(String local, Attributes attrs)
          Invoked when the starting of the stdin tag is reached.
private  void handleStdoutTagStart(String local, Attributes attrs)
          Invoked when the starting of the stdout tag is reached.
private  void handleUsesPFNTagStart(String local, Attributes attrs)
          Invoked when start of the pfn element nested in uses element is encountered
private  void handleUsesTagEnd()
          Handles the end of a uses tag.
private  void handleUsesTagStart(String local, Attributes attrs)
          Invoked when the starting of the uses element is got.
 String ignoreWhitespace(String str)
          Our own implementation for ignorable whitespace.
static void main(String[] args)
          The main program.
 void setDAXCallback(Callback c)
          Set the DAXCallback for the parser to call out to.
 float shiftRight(String value)
          Returns a float with the decimal point shifted right till the end.
 void startElement(String uri, String local, String raw, Attributes attrs)
          Overriding the empty implementation provided by DefaultHandler of ContentHandler.
 void startParser(String daxFileName)
          This starts the parsing of the file by the parser.
protected  boolean useDoubleNegative(String daxVersion)
          Determines whether to use a doubleNegative or not.
 
Methods inherited from class edu.isi.pegasus.planner.parser.Parser
characters, ignoreWhitespace, setDocumentLocator, setParserFeature, setSchemaLocations, testForFile
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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_NAMESPACE

public static final String SCHEMA_NAMESPACE
URI namespace

See Also:
Constant Field Values

DAX_VERSION_WITHOUT_DOUBLE_NEGATIVE

private static final String DAX_VERSION_WITHOUT_DOUBLE_NEGATIVE
The constant designating the version when the double negative transfer and registration flags were removed.

See Also:
Constant Field Values

mExecutionToHintsNamespace

private static Map<String,String> mExecutionToHintsNamespace
The map that maps keys in execution tag to hints namespace.


mDaxSchemaVersion

public String mDaxSchemaVersion

infoAboutAllFilesRecv

private boolean infoAboutAllFilesRecv
A boolean variable set to true when we have got all the logical filenames. After this all the filename tags are not added in Vector mLogicalFilesInADag This is because the DAX file specifies all the input and output files in the starting, and then in the job tags also the filename tags are nested.


mCallback

private Callback mCallback
The handle to the class implementing the callback interface.


mProfileKey

private String mProfileKey
For holding the key attribute in profile tag.


mNamespace

private String mNamespace
For holding the namespace if specified in the Profile Element.


mProfileTag

private boolean mProfileTag
Set as and when Profile and Argument tags are started and ended. Need to in order to determine the nested filename tags which may appear in these elements.


mArgumentTag

private boolean mArgumentTag

mCurrentChildId

private String mCurrentChildId
These store the current child element for the child parent relationship. We get nested parent elements in a child element. Hence the child remains the same while the parent id for the relationship varies.


mParents

private List<PCRelation> mParents
The list of parents of a node referred to by mCurrentChildId.


mCurrentJobSubInfo

private Job mCurrentJobSubInfo
Holds information regarding the current job being parsed. It's scope can be seen as the job element.


mWholeCommandString

private String mWholeCommandString
All the arguments to a particular job.


mVJobInpFiles

private Set mVJobInpFiles
Holds the input files for a particular job making the aDag. They are Vector of PegasusFile Objects which store the transiency information of each logical file.

See Also:
org.griphyn.cPlanner.classes.PegasusFile

mVJobOutFiles

private Set mVJobOutFiles
Holds the output files for a particular job making the aDag. They are vector of PegasusFile Objects which store the transiency information of each logical file.

See Also:
org.griphyn.cPlanner.classes.PegasusFile

mUseDoubleNegative

private boolean mUseDoubleNegative
A boolean indicating whether to use the double negative flags for transfer and register or not.


mJobPrefix

protected String mJobPrefix
The job prefix that needs to be applied to the job file basenames.


mUsesLinkType

private String mUsesLinkType
The uses link type for a file when uses tag is parsed.


mUsesPegasusFile

private PegasusFile mUsesPegasusFile
The PegasusFile object that a uses tag corresponds to.


mDAXLFN

private String mDAXLFN
The file attribute encountered in the dax element.


mDAGLFN

private String mDAGLFN
The file attribute encountered in the dag element.

Constructor Detail

DAXParser2

public DAXParser2(PegasusBag bag)
The default constructor

Parameters:
bag - the bag of objects that is useful for initialization.
Method Detail

executionToHintsNamespace

private static String executionToHintsNamespace(String key)
Maps the execution key to corresponding key in hints namespace.

Parameters:
key - the key in execution tag
Returns:
corresponding key in hints namespace else null

setDAXCallback

public void setDAXCallback(Callback c)
Set the DAXCallback for the parser to call out to.

Specified by:
setDAXCallback in interface DAXParser
Parameters:
c - the callback

getDAXCallback

public Callback getDAXCallback()
Retuns the DAXCallback for the parser

Specified by:
getDAXCallback in interface DAXParser
Returns:
the callback

startParser

public void startParser(String daxFileName)
This starts the parsing of the file by the parser.

Specified by:
startParser in class Parser
Parameters:
daxFileName - the path/uri to the XML file you want to parse.

startElement

public void startElement(String uri,
                         String local,
                         String raw,
                         Attributes attrs)
                  throws SAXException
Overriding the empty implementation provided by DefaultHandler of ContentHandler. This receives the notification from the sacks parser when start tag of an element comes

Specified by:
startElement in interface ContentHandler
Specified by:
startElement in class Parser
Throws:
SAXException

getVersionOfDAX

public String getVersionOfDAX(String file)
A convenience method that tries to determine the version of the dax schema by reading ahead in the DAX file, and searching for the version attribue in the file.

Parameters:
file - the name of the dax file.

extractVersionFromSchema

public String extractVersionFromSchema(String schema)
Determines the version of the DAX as specified in a schema string.

Parameters:
schema - the schema string as specified in the root element of the DAX.
Returns:
the version.

getSchemaOfDocument

public String getSchemaOfDocument(String file)
A convenience method that tries to get the name of the schema the document refers to. It returns the value of the xsi:schemaLocation.

Parameters:
file - the name of the dax file.

handleAdagTagStart

private void handleAdagTagStart(String local,
                                Attributes attrs)
Invoked when the starting of the adag element is got. Information received is name : the name of the ADag count: Chimera can generate multiple abstract dags for a request. index: what is the index of the ADag being passed. Should vary between 0 and count - 1.


handleExecutionTagStart

private void handleExecutionTagStart(String local,
                                     Attributes attrs)
Replaces the keys associated with the execution tag, with the corresponding keys in the hints profile namespace

Parameters:
local - the local name of the leemnt
attrs - the attributes

handleFilenameTagStart

private void handleFilenameTagStart(String local,
                                    Attributes attrs)
Invoked when the starting of the filename element is got.


handleMetadataTagStart

private void handleMetadataTagStart(String local,
                                    Attributes attrs)
Metadata parsing is ignored for time being.

Parameters:
local -
attrs -

handleMetadataTagEnd

private void handleMetadataTagEnd()
Resets the text content buffer


handleUsesTagStart

private void handleUsesTagStart(String local,
                                Attributes attrs)
Invoked when the starting of the uses element is got. Uses tag is used to denote all the files a particular job uses, be it as input , output or silent.


handleUsesTagEnd

private void handleUsesTagEnd()
Handles the end of a uses tag.


handleUsesPFNTagStart

private void handleUsesPFNTagStart(String local,
                                   Attributes attrs)
Invoked when start of the pfn element nested in uses element is encountered

Parameters:
local - the local name of the element
attrs - the map of attributes and values in the element tag

handleDAGTagStart

private void handleDAGTagStart(String local,
                               Attributes attrs)
Invoked when the starting of the dax element is retrieved. The DAG element extends on the job element.

Parameters:
local - the local name of the element
attrs - the attributes

handleDAXTagStart

private void handleDAXTagStart(String local,
                               Attributes attrs)
Invoked when the starting of the dax element is retrieved. The DAX element is a extends on the job element.

Parameters:
local - the local name of the element
attrs - the attributes

handleJobTagStart

private void handleJobTagStart(String local,
                               Attributes attrs)
Invoked when the starting of the job element is got. The following information is retrieved from the tag name : name of the job, which is the logical name of the job. namespace : the namespace with which the transformation corresponding to the job is associated. version : the version of the transformation.

Parameters:
local - the local name of the element
attrs - the attributes

handleJobTagStart

private void handleJobTagStart(Job job)
Invoked when the starting of the job element is got. The following information is retrieved from the tag name : name of the job, which is the logical name of the job. namespace : the namespace with which the transformation corresponding to the job is associated. version : the version of the transformation.

Parameters:
job - the Job object

handleDAGTagEnd

private void handleDAGTagEnd()
Invoked when the end of the dag tag is reached. It removes the dag file referred in the element.


handleDAXTagEnd

private void handleDAXTagEnd()
Invoked when the end of the job tag is reached.


handleJobTagEnd

private void handleJobTagEnd()
Invoked when the end of the job tag is reached.


handleProfileTagStart

private void handleProfileTagStart(String local,
                                   Attributes attrs)
Invoked when the starting of the profile element is got.


handleExecutionTagEnd

private void handleExecutionTagEnd()
Invoked when the end of the execution element is reached.


constructTCEntryFromJobHints

private TransformationCatalogEntry constructTCEntryFromJobHints(Job job)
Constructs a TC entry object from the contents of a job. The architecture assigned to this entry is default ( INTEL32::LINUX ) and resource id is set to unknown.

Parameters:
job - the job object
Returns:
constructed TransformationCatalogEntry

handleProfileTagEnd

private void handleProfileTagEnd()
Invoked when the end of the profile element is got. Here we handle all the namespaces supported by Chimera at present.


handleChildTagStart

private void handleChildTagStart(String local,
                                 Attributes attrs)
Invoked when the starting of the child element is got. The child element gives us the child of an edge of the dag. The edge being parent->child.


handleChildTagEnd

private void handleChildTagEnd()
This passes the child and it's parents list to the callback object.


handleParentTagStart

private void handleParentTagStart(String local,
                                  Attributes attrs)
Invoked when the starting of the parent element is got. The child element gives us the child of an edge of the dag. The edge being parent->child.


handleArgumentTagStart

private void handleArgumentTagStart(String local,
                                    Attributes attrs)
Invoked when the starting of the Argument Tag is reached. Just set a boolean variable


handleArgumentTagEnd

private void handleArgumentTagEnd()
Invoked when the end of the Argument Tag is reached. The buffers are reset


ignoreWhitespace

public String ignoreWhitespace(String str)
Our own implementation for ignorable whitespace. A String that holds the contents of data passed as text by the underlying parser. The whitespaces at the end are replaced by one whitespace.

Overrides:
ignoreWhitespace in class Parser
Parameters:
str - The string that contains whitespaces.
Returns:
String corresponding to the trimmed version.

handleStdoutTagStart

private void handleStdoutTagStart(String local,
                                  Attributes attrs)
Invoked when the starting of the stdout tag is reached. Used to specify the stdout of the application by the user. It can be a file also.


handleStdinTagStart

private void handleStdinTagStart(String local,
                                 Attributes attrs)
Invoked when the starting of the stdin tag is reached. Used to specify the stdout of the application by the user. It can be a file also.


handleStderrTagStart

private void handleStderrTagStart(String local,
                                  Attributes attrs)
Invoked when the starting of the stdout tag is reached. Used to specify the stderr of the application by the user. It can be a file also.


endElement

public void endElement(String uri,
                       String localName,
                       String qName)
Overrides the default implementation when the elements end tag comes. This method is called automatically by the Sax parser when the end tag of an element comes in the xml file.

Specified by:
endElement in interface ContentHandler
Specified by:
endElement in class Parser

endDocument

public void endDocument()
Here we have all the elements in our data structure. This is called automatically when the end of the XML file is reached.

Specified by:
endDocument in interface ContentHandler
Specified by:
endDocument in class Parser

main

public static void main(String[] args)
The main program. The DAXParser2 can be run standalone, by which it just parses the file and populates the required data objects.


getSchemaNamespace

public String getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.

Specified by:
getSchemaNamespace in class Parser
Returns:
the schema namespace

getSchemaLocation

public String getSchemaLocation()
Helps the load database to locate the DAX XML schema, if available. Please note that the schema location URL in the instance document is only a hint, and may be overriden by the findings of this method.

Specified by:
getSchemaLocation in class Parser
Returns:
a location pointing to a definition document of the XML schema that can read VDLx. Result may be null, if such a document is unknown or unspecified.

useDoubleNegative

protected boolean useDoubleNegative(String daxVersion)
Determines whether to use a doubleNegative or not.

Parameters:
daxVersion - the version of the dax as determined.
Returns:
boolean

shiftRight

public float shiftRight(String value)
Returns a float with the decimal point shifted right till the end. Is necessary for comparing a String "1.10" with a String "1.9".

Parameters:
value - the value that has to be shifted right.
Returns:
the float value, with the decimal point shifted or -1 in case of error.


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