Class DAXParser2

  • All Implemented Interfaces:
    DAXParser, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.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$
    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

      Fields 
      Modifier and Type Field Description
      private static java.lang.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 java.lang.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 java.lang.String mDAGLFN
      The file attribute encountered in the dag element.
      private java.lang.String mDAXLFN
      The file attribute encountered in the dax element.
      java.lang.String mDaxSchemaVersion  
      private static java.util.Map<java.lang.String,​java.lang.String> mExecutionToHintsNamespace
      The map that maps keys in execution tag to hints namespace.
      protected java.lang.String mJobPrefix
      The job prefix that needs to be applied to the job file basenames.
      private java.lang.String mNamespace
      For holding the namespace if specified in the Profile Element.
      private java.util.List<PCRelation> mParents
      The list of parents of a node referred to by mCurrentChildId.
      private java.lang.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 java.lang.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 java.util.Set mVJobInpFiles
      Holds the input files for a particular job making the aDag.
      private java.util.Set mVJobOutFiles
      Holds the output files for a particular job making the aDag.
      private java.lang.String mWholeCommandString
      All the arguments to a particular job.
      static java.lang.String SCHEMA_LOCATION
      The "not-so-official" location URL of the DAX schema definition.
      static java.lang.String SCHEMA_NAMESPACE
      URI namespace
    • Constructor Summary

      Constructors 
      Constructor Description
      DAXParser2​(PegasusBag bag)
      The default constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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​(java.lang.String uri, java.lang.String localName, java.lang.String qName)
      Overrides the default implementation when the elements end tag comes.
      private static java.lang.String executionToHintsNamespace​(java.lang.String key)
      Maps the execution key to corresponding key in hints namespace.
      java.lang.String extractVersionFromSchema​(java.lang.String schema)
      Determines the version of the DAX as specified in a schema string.
      Callback getDAXCallback()
      Retuns the DAXCallback for the parser
      java.lang.String getSchemaLocation()
      Helps the load database to locate the DAX XML schema, if available.
      java.lang.String getSchemaNamespace()
      Returns the XML schema namespace that a document being parsed conforms to.
      java.lang.String getSchemaOfDocument​(java.lang.String file)
      A convenience method that tries to get the name of the schema the document refers to.
      java.lang.String getVersionOfDAX​(java.lang.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​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.Attributes attrs)
      Replaces the keys associated with the execution tag, with the corresponding keys in the hints profile namespace
      private void handleFilenameTagStart​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the job element is got.
      private void handleMetadataTagEnd()
      Resets the text content buffer
      private void handleMetadataTagStart​(java.lang.String local, org.xml.sax.Attributes attrs)
      Metadata parsing is ignored for time being.
      private void handleParentTagStart​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the profile element is got.
      private void handleStderrTagStart​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the stdout tag is reached.
      private void handleStdinTagStart​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the stdin tag is reached.
      private void handleStdoutTagStart​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the stdout tag is reached.
      private void handleUsesPFNTagStart​(java.lang.String local, org.xml.sax.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​(java.lang.String local, org.xml.sax.Attributes attrs)
      Invoked when the starting of the uses element is got.
      java.lang.String ignoreWhitespace​(java.lang.String str)
      Our own implementation for ignorable whitespace.
      static void main​(java.lang.String[] args)
      The main program.
      void setDAXCallback​(Callback c)
      Set the DAXCallback for the parser to call out to.
      float shiftRight​(java.lang.String value)
      Returns a float with the decimal point shifted right till the end.
      void startElement​(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs)
      Overriding the empty implementation provided by DefaultHandler of ContentHandler.
      void startParser​(java.lang.String daxFileName)
      This starts the parsing of the file by the parser.
      protected boolean useDoubleNegative​(java.lang.String daxVersion)
      Determines whether to use a doubleNegative or not.
      • 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 java.lang.String SCHEMA_LOCATION
        The "not-so-official" location URL of the DAX schema definition.
        See Also:
        Constant Field Values
      • SCHEMA_NAMESPACE

        public static final java.lang.String SCHEMA_NAMESPACE
        URI namespace
        See Also:
        Constant Field Values
      • DAX_VERSION_WITHOUT_DOUBLE_NEGATIVE

        private static final java.lang.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 java.util.Map<java.lang.String,​java.lang.String> mExecutionToHintsNamespace
        The map that maps keys in execution tag to hints namespace.
      • mDaxSchemaVersion

        public java.lang.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 java.lang.String mProfileKey
        For holding the key attribute in profile tag.
      • mNamespace

        private java.lang.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 java.lang.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 java.util.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 java.lang.String mWholeCommandString
        All the arguments to a particular job.
      • mVJobInpFiles

        private java.util.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 java.util.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 java.lang.String mJobPrefix
        The job prefix that needs to be applied to the job file basenames.
      • mUsesLinkType

        private java.lang.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 java.lang.String mDAXLFN
        The file attribute encountered in the dax element.
      • mDAGLFN

        private java.lang.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 java.lang.String executionToHintsNamespace​(java.lang.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​(java.lang.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​(java.lang.String uri,
                                 java.lang.String local,
                                 java.lang.String raw,
                                 org.xml.sax.Attributes attrs)
                          throws org.xml.sax.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 org.xml.sax.ContentHandler
        Specified by:
        startElement in class Parser
        Throws:
        org.xml.sax.SAXException
      • getVersionOfDAX

        public java.lang.String getVersionOfDAX​(java.lang.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 java.lang.String extractVersionFromSchema​(java.lang.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 java.lang.String getSchemaOfDocument​(java.lang.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​(java.lang.String local,
                                        org.xml.sax.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​(java.lang.String local,
                                             org.xml.sax.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​(java.lang.String local,
                                            org.xml.sax.Attributes attrs)
        Invoked when the starting of the filename element is got.
      • handleMetadataTagStart

        private void handleMetadataTagStart​(java.lang.String local,
                                            org.xml.sax.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​(java.lang.String local,
                                        org.xml.sax.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​(java.lang.String local,
                                           org.xml.sax.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​(java.lang.String local,
                                       org.xml.sax.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​(java.lang.String local,
                                       org.xml.sax.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​(java.lang.String local,
                                       org.xml.sax.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​(java.lang.String local,
                                           org.xml.sax.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​(java.lang.String local,
                                         org.xml.sax.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​(java.lang.String local,
                                          org.xml.sax.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​(java.lang.String local,
                                            org.xml.sax.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 java.lang.String ignoreWhitespace​(java.lang.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​(java.lang.String local,
                                          org.xml.sax.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​(java.lang.String local,
                                         org.xml.sax.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​(java.lang.String local,
                                          org.xml.sax.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​(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.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 org.xml.sax.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 org.xml.sax.ContentHandler
        Specified by:
        endDocument in class Parser
      • main

        public static void main​(java.lang.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 java.lang.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 java.lang.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​(java.lang.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​(java.lang.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.