001: /**
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found at $PEGASUS_HOME/GTPL or
004: * http://www.globus.org/toolkit/download/license.html.
005: * This notice must appear in redistributions of this file
006: * with or without modification.
007: *
008: * Redistributions of this Software, with or without modification, must reproduce
009: * the GTPL in:
010: * (1) the Software, or
011: * (2) the Documentation or
012: * some other similar material which is provided with the Software (if any).
013: *
014: * Copyright 1999-2004
015: * University of Chicago and The University of Southern California.
016: * All rights reserved.
017: */package org.griphyn.cPlanner.poolinfo;
018:
019: import org.griphyn.cPlanner.common.LogManager;
020:
021: import org.griphyn.cPlanner.parser.ConfigXmlParser;
022:
023: /**
024: * It gets the information about a pool by reading the pool config xml that is
025: * generated from querying mds or using the static information provided by the
026: * user at the submit host.
027: *
028: *
029: * @author Gaurang Mehta gmehta@isi.edu
030: * @author Karan Vahi vahi@isi.edu
031: * @version $Revision: 50 $
032: */
033: public class XML extends Abstract {
034:
035: private static XML mPoolHandle = null;
036:
037: /**
038: * The private constructor that is called only once, when the Singleton is
039: * invoked for the first time.
040: *
041: * @param poolProvider the path to the file that contains the pool
042: * information in the xml format.
043: */
044: private XML(String poolProvider) {
045: loadSingletonObjects();
046:
047: if (poolProvider == null) {
048: throw new RuntimeException(
049: " Wrong Call to the Singleton invocation of Site Catalog");
050: }
051:
052: this .mPoolProvider = poolProvider;
053: ConfigXmlParser cp = new ConfigXmlParser(mPoolProvider, mProps);
054: mPoolConfig = cp.getPoolConfig();
055: mLogger.log("SC Mode being used is " + this .getPoolMode(),
056: LogManager.CONFIG_MESSAGE_LEVEL);
057: mLogger.log("SC File being used is " + this .mPoolProvider,
058: LogManager.CONFIG_MESSAGE_LEVEL);
059: mLogger.log(mPoolConfig.getSites().size()
060: + " sites loaded in memory",
061: LogManager.DEBUG_MESSAGE_LEVEL);
062: }
063:
064: /**
065: * The private constructor that is called to return a non singleton instance
066: * of the class.
067: *
068: * @param poolProvider the path to the file that contains the pool
069: * information in the xml format.
070: * @param propFileName the name of the properties file that needs to be
071: * picked up from PEGASUS_HOME/etc directory.If it is null,
072: * then the default properties file should be picked up.
073: *
074: */
075: private XML(String poolProvider, String propFileName) {
076: loadNonSingletonObjects(propFileName);
077: this .mPoolProvider = poolProvider;
078: ConfigXmlParser cp = new ConfigXmlParser(mPoolProvider, mProps);
079: mPoolConfig = cp.getPoolConfig();
080: mLogger.log("SC Mode being used is " + this .getPoolMode(),
081: LogManager.CONFIG_MESSAGE_LEVEL);
082: mLogger.log("SC File being used is " + this .mPoolProvider,
083: LogManager.CONFIG_MESSAGE_LEVEL);
084: mLogger.log(mPoolConfig.getSites().size()
085: + " sites loaded in memory",
086: LogManager.DEBUG_MESSAGE_LEVEL);
087:
088: }
089:
090: /**
091: * Returns a textual description about the pool mode that is
092: * implemented by this class. It is purely informative.
093: *
094: * @return String corresponding to the description.
095: */
096: public String getPoolMode() {
097: String st = "XML Site catalog";
098: return st;
099: }
100:
101: /**
102: * The method returns a singleton instance of the derived InfoProvider class.
103: *
104: * @param poolProvider the path to the file containing the pool information.
105: * @param propFileName the name of the properties file that needs to be
106: * picked up from PEGASUS_HOME/etc directory. In the singleton
107: * case only the default properties file is picked up.
108: *
109: * @return a singleton instance of this class.
110: */
111: public static PoolInfoProvider singletonInstance(
112: String poolProvider, String propFileName) {
113:
114: if (mPoolHandle == null) {
115: mPoolHandle = new XML(poolProvider);
116: }
117: return mPoolHandle;
118: }
119:
120: /**
121: * The method that returns a Non Singleton instance of the dervived
122: * InfoProvider class. This method if invoked should also ensure that all
123: * other internal Pegasus objects like PegasusProperties are invoked in a non
124: * singleton manner.
125: *
126: * @param poolProvider the path to the file containing the pool information.
127: * @param propFileName the name of the properties file that needs to be
128: * picked up from PEGASUS_HOME/etc directory. If it is null,
129: * then the default file should be picked up.
130: *
131: * @return the non singleton instance of the pool provider.
132: *
133: */
134: public static PoolInfoProvider nonSingletonInstance(
135: String poolProvider, String propFileName) {
136:
137: mPoolHandle = new XML(poolProvider, propFileName);
138: return mPoolHandle;
139: }
140:
141: }
|