Class XML2
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- edu.isi.pegasus.planner.parser.Parser
-
- edu.isi.pegasus.planner.catalog.site.impl.XML2
-
- All Implemented Interfaces:
Catalog
,SiteCatalog
,org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
public class XML2 extends Parser implements SiteCatalog
A back port to old site catalog schema for the current Site Catalog API This class parses XML documents that conform to site catalog schema version 2.http://pegasus.isi.edu/schema/sc-2.0.xsd
- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description private GridFTPServer
gftp
private java.lang.String
m_key
private java.lang.String
m_namespace
PoolConfig
m_pconfig
private SiteInfo
m_pool_info
private java.lang.String
mFilename
The Site Catalog file to be parser.private LogManager
mLogger
The Logging instance.private SiteStore
mSiteStore
Stores sites in memorystatic java.lang.String
SCHEMA_LOCATION
The "not-so-official" location URL of the VDLx schema definition.static java.lang.String
SCHEMA_NAMESPACE
uri namespace-
Fields inherited from class edu.isi.pegasus.planner.parser.Parser
DEFAULT_PARSER_NAME, mAdjFName, mLocator, mLogMsg, mParser, mProps, mTextContent, mTextString
-
Fields inherited from interface edu.isi.pegasus.planner.catalog.Catalog
DB_ALL_PREFIX
-
Fields inherited from interface edu.isi.pegasus.planner.catalog.SiteCatalog
c_prefix, VERSION
-
-
Constructor Summary
Constructors Constructor Description XML2()
The default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the connection to backend file.boolean
connect(java.lang.String filename)
Initializes the Site Catalog Parser instance for the file.boolean
connect(java.util.Properties props)
Establishes a connection to the file from the properties.void
endDocument()
This is called automatically when the end of the XML file is reached.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
An empty implementation is provided by DefaultHandler class.PoolConfig
getPoolConfig()
This class returns the reference to thePooConfig
object containing information about all the pools.java.lang.String
getSchemaLocation()
Helps the load database to locate the XML schema, if available.java.lang.String
getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.private void
handleConfigTagEnd()
Handles the end of the Xml files.private PoolConfig
handleConfigTagStart()
private static void
handleGridFtpBandwidthTagEnd()
private void
handleGridFtpBandwidthTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
sk added function to handle gridftpbandwidth tagprivate void
handleGridFtpTagEnd()
sk made changes to the following function to set GRIDFTPServer instead of setting it in fn handleGridFtpTagStart()private void
handleGridFtpTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
private static void
handleJobManagerTagEnd()
Handles the end of the JobManager Tagprivate void
handleJobManagerTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
This method handles the start of a jobmanager tag.private static void
handleLRCTagEnd()
Handles the end of the LRC Tagprivate void
handleLRCTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
private void
handlePoolTagEnd()
Handles the end of the pool tag.private SiteInfo
handlePoolTagStart(PoolConfig pcfg, org.xml.sax.Attributes attrs)
private void
handleProfileTagEnd(SiteInfo pinfo)
Handles the end of the Profile tag.private void
handleProfileTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
private void
handleWorkDirectoryTagEnd(SiteInfo pinfo)
This method handles the Workdirectory tg end.private void
handleWorkDirectoryTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs)
Handles the WorkDirectory Tag Start.int
insert(SiteCatalogEntry entry)
Not implemented as yet.boolean
isClosed()
Returns if the connection is closed or not.java.util.Set<java.lang.String>
list()
Lists the site handles for all the sites in the Site Catalog.int
load(java.util.List<java.lang.String> sites)
Loads up the Site Catalog implementation with the sites whose site handles are specified.SiteCatalogEntry
lookup(java.lang.String handle)
Retrieves theSiteCatalogEntry
for a site.int
remove(java.lang.String handle)
Not yet implemented as yet.void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
An empty implementation is provided by DefaultHandler of ContentHandler.void
startParser(java.lang.String configxml)
Start the parser.-
Methods inherited from class edu.isi.pegasus.planner.parser.Parser
characters, ignoreWhitespace, ignoreWhitespace, setDocumentLocator, setParserFeature, setSchemaLocations, testForFile
-
-
-
-
Field Detail
-
SCHEMA_LOCATION
public static final java.lang.String SCHEMA_LOCATION
The "not-so-official" location URL of the VDLx schema definition.- See Also:
- Constant Field Values
-
SCHEMA_NAMESPACE
public static final java.lang.String SCHEMA_NAMESPACE
uri namespace- See Also:
- Constant Field Values
-
m_pconfig
public PoolConfig m_pconfig
-
m_pool_info
private SiteInfo m_pool_info
-
m_namespace
private java.lang.String m_namespace
-
m_key
private java.lang.String m_key
-
gftp
private GridFTPServer gftp
-
mLogger
private LogManager mLogger
The Logging instance.
-
mSiteStore
private SiteStore mSiteStore
Stores sites in memory
-
mFilename
private java.lang.String mFilename
The Site Catalog file to be parser.
-
-
Method Detail
-
connect
public boolean connect(java.util.Properties props) throws SiteCatalogException
Establishes a connection to the file from the properties. You will need to specify a "file" property to point to the location of the on-disk instance.- Specified by:
connect
in interfaceCatalog
- Parameters:
props
- is the property table with sufficient settings to to connect to the implementation.- Returns:
- true if connected, false if failed to connect.
- Throws:
SiteCatalogException
-
connect
public boolean connect(java.lang.String filename)
Initializes the Site Catalog Parser instance for the file.- Parameters:
filename
- is the name of the file to read.- Returns:
- true,
-
close
public void close()
Close the connection to backend file.
-
isClosed
public boolean isClosed()
Returns if the connection is closed or not.- Specified by:
isClosed
in interfaceCatalog
- Returns:
- boolean
- See Also:
Catalog.close()
-
load
public int load(java.util.List<java.lang.String> sites) throws SiteCatalogException
Loads up the Site Catalog implementation with the sites whose site handles are specified. This is a convenience method, that can allow the backend implementations to maintain soft state if required. If the implementation chooses not to implement this, just do an empty implementation. The site handle * is a special handle designating all sites are to be loaded.- Specified by:
load
in interfaceSiteCatalog
- Parameters:
sites
- the list of sites to be loaded.- Returns:
- the number of sites loaded.
- Throws:
SiteCatalogException
- in case of error.
-
insert
public int insert(SiteCatalogEntry entry) throws SiteCatalogException
Not implemented as yet.- Specified by:
insert
in interfaceSiteCatalog
- Parameters:
entry
- the entry- Returns:
- number of entries inserted
- Throws:
SiteCatalogException
-
list
public java.util.Set<java.lang.String> list() throws SiteCatalogException
Lists the site handles for all the sites in the Site Catalog.- Specified by:
list
in interfaceSiteCatalog
- Returns:
- A set of site handles.
- Throws:
SiteCatalogException
- in case of error.
-
lookup
public SiteCatalogEntry lookup(java.lang.String handle) throws SiteCatalogException
Retrieves theSiteCatalogEntry
for a site.- Specified by:
lookup
in interfaceSiteCatalog
- Parameters:
handle
- the site handle / identifier.- Returns:
- SiteCatalogEntry in case an entry is found , or
null
if no match is found. - Throws:
SiteCatalogException
- in case of error.
-
remove
public int remove(java.lang.String handle) throws SiteCatalogException
Not yet implemented as yet.- Specified by:
remove
in interfaceSiteCatalog
- Parameters:
handle
- the site to be removed- Returns:
- number of entries removed.
- Throws:
SiteCatalogException
-
startParser
public void startParser(java.lang.String configxml)
Description copied from class:Parser
Start the parser. This starts the parsing of the file by the parser.- Specified by:
startParser
in classParser
- Parameters:
configxml
- the path to the XML file you want to parse.
-
endDocument
public void endDocument()
Description copied from class:Parser
This is called automatically when the end of the XML file is reached.- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Specified by:
endDocument
in classParser
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Description copied from class:Parser
An empty implementation is provided by DefaultHandler class. This method is called automatically by the Sax parser when the end tag of an element comes in the xml file. Any parser class should implement this method- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Specified by:
endElement
in classParser
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
Description copied from class:Parser
An empty implementation is provided by DefaultHandler of ContentHandler. This method receives the notification from the sacks parser when start tag of an element comes. Any parser class must implement this method.- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Specified by:
startElement
in classParser
-
getSchemaNamespace
public java.lang.String getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.- Specified by:
getSchemaNamespace
in classParser
- Returns:
- the schema namespace
-
getSchemaLocation
public java.lang.String getSchemaLocation()
Description copied from class:Parser
Helps the load database to locate the 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 classParser
- 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.
-
handleConfigTagStart
private PoolConfig handleConfigTagStart()
- Returns:
- PoolConfig Returns a new
PoolConfig
object when it encounters start of XML.
- See Also:
org.griphyn.cPlanner.classes.PoolConfig
-
handlePoolTagStart
private SiteInfo handlePoolTagStart(PoolConfig pcfg, org.xml.sax.Attributes attrs) throws java.lang.Exception
- Parameters:
pcfg
- Takes the PoolConfig class.attrs
- Takes the atrributes returned in XML.- Returns:
- SiteInfo returns the reference to the PooInfo ojject
- Throws:
java.lang.Exception
- See Also:
org.griphyn.cPlanner.classes.SiteInfo
,org.griphyn.cPlanner.classes.PoolConfig
-
handleProfileTagStart
private void handleProfileTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
- Parameters:
pinfo
- Poolinfo object that is to be populatedattrs
- Attributes for the element- Throws:
java.lang.Exception
-
handleLRCTagStart
private void handleLRCTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
- Parameters:
pinfo
- Poolinfo object that is to be populatedattrs
- Attributes for the element- Throws:
java.lang.Exception
-
handleGridFtpTagStart
private void handleGridFtpTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
- Parameters:
pinfo
- Poolinfo object that is to be populatedattrs
- Attributes for the element- Throws:
java.lang.Exception
-
handleGridFtpBandwidthTagStart
private void handleGridFtpBandwidthTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
sk added function to handle gridftpbandwidth tag- Parameters:
pinfo
- Poolinfo object that is to be populatedattrs
- Attributes for the element- Throws:
java.lang.Exception
-
handleJobManagerTagStart
private void handleJobManagerTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
This method handles the start of a jobmanager tag.- Parameters:
pinfo
- ThePoolInfo
object which will hold the jobmanager informationattrs
- The attributes about the jobmanager tag returned from the XML.- Throws:
java.lang.Exception
- See Also:
org.griphyn.cPlanner.classes.SiteInfo
-
handleWorkDirectoryTagStart
private void handleWorkDirectoryTagStart(SiteInfo pinfo, org.xml.sax.Attributes attrs) throws java.lang.Exception
Handles the WorkDirectory Tag Start.- Parameters:
pinfo
- Takes a SiteInfo object for which the work directory is.attrs
- Takes the attributes returned from the XML by the parser.- Throws:
java.lang.Exception
- See Also:
org.griphyn.cPlanner.classes.SiteInfo
-
handleConfigTagEnd
private void handleConfigTagEnd()
Handles the end of the Xml files.
-
handlePoolTagEnd
private void handlePoolTagEnd()
Handles the end of the pool tag.
-
handleProfileTagEnd
private void handleProfileTagEnd(SiteInfo pinfo) throws java.lang.RuntimeException
Handles the end of the Profile tag.- Parameters:
pinfo
-PoolInfo
object for which the profiles are collected.- Throws:
java.lang.Exception
java.lang.RuntimeException
- See Also:
org.griphyn.cPlanner.classes.SiteInfo
-
handleLRCTagEnd
private static void handleLRCTagEnd()
Handles the end of the LRC Tag
-
handleGridFtpTagEnd
private void handleGridFtpTagEnd() throws java.lang.RuntimeException
sk made changes to the following function to set GRIDFTPServer instead of setting it in fn handleGridFtpTagStart()- Throws:
java.lang.RuntimeException
-
handleGridFtpBandwidthTagEnd
private static void handleGridFtpBandwidthTagEnd()
-
handleJobManagerTagEnd
private static void handleJobManagerTagEnd()
Handles the end of the JobManager Tag
-
handleWorkDirectoryTagEnd
private void handleWorkDirectoryTagEnd(SiteInfo pinfo) throws java.lang.RuntimeException
This method handles the Workdirectory tg end.- Parameters:
pinfo
- Takes the PoolInfo object.- Throws:
java.lang.Exception
java.lang.RuntimeException
- See Also:
org.griphyn.cPlanner.classes.SiteInfo
-
getPoolConfig
public PoolConfig getPoolConfig()
This class returns the reference to thePooConfig
object containing information about all the pools.- Returns:
- returns a reference to the
PoolConfig
object which contains all the pools. - See Also:
org.griphyn.cPlanner.classes.PoolConfig
-
-