0001: /*
0002: * This file or a portion of this file is licensed under the terms of
0003: * the Globus Toolkit Public License, found in file GTPL, or at
0004: * http://www.globus.org/toolkit/download/license.html. This notice must
0005: * appear in redistributions of this file, with or without modification.
0006: *
0007: * Redistributions of this Software, with or without modification, must
0008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
0009: * some other similar material which is provided with the Software (if
0010: * any).
0011: *
0012: * Copyright 1999-2004 University of Chicago and The University of
0013: * Southern California. All rights reserved.
0014: */
0015:
0016: package org.griphyn.cPlanner.common;
0017:
0018: import org.griphyn.cPlanner.classes.NameValue;
0019:
0020: import org.griphyn.cPlanner.poolinfo.PoolMode;
0021:
0022: import org.griphyn.common.catalog.transformation.TCMode;
0023:
0024: import org.griphyn.common.util.VDSProperties;
0025: import org.griphyn.common.util.Boolean;
0026:
0027: import java.io.File;
0028: import java.io.IOException;
0029: import java.io.OutputStream;
0030: import java.io.FileOutputStream;
0031:
0032: import java.util.Collections;
0033: import java.util.List;
0034: import java.util.MissingResourceException;
0035: import java.util.Properties;
0036: import java.util.Set;
0037: import java.util.HashSet;
0038:
0039: /**
0040: * A Central Properties class that keeps track of all the properties used by
0041: * Pegasus. All other classes access the methods in this class to get the value
0042: * of the property. It access the VDSProperties class to read the property file.
0043: *
0044: * @author Karan Vahi
0045: * @author Gaurang Mehta
0046: *
0047: * @version $Revision: 418 $
0048: *
0049: * @see org.griphyn.common.util.VDSProperties
0050: */
0051: public class PegasusProperties {
0052:
0053: //Replica Catalog Constants
0054: public static final String DEFAULT_RC_COLLECTION = "GriphynData";
0055:
0056: public static final String DEFAULT_RLI_URL = null;
0057:
0058: public static final String DEFAULT_RLS_QUERY_MODE = "bulk";
0059:
0060: public static final String DEFAULT_RLS_EXIT_MODE = "error";
0061:
0062: public static final String DEFAULT_REPLICA_MODE = "rls";
0063:
0064: public static final String DEFAULT_RLS_QUERY_ATTRIB = "false";
0065:
0066: public static final String DEFAULT_LRC_IGNORE_URL = null;
0067:
0068: public static final String DEFAULT_RLS_TIMEOUT = "30";
0069:
0070: public static final String DEFAULT_EXEC_DIR = "";
0071:
0072: public static final String DEFAULT_STORAGE_DIR = "";
0073:
0074: public static final String DEFAULT_TC_MODE = TCMode.DEFAULT_TC_CLASS;
0075:
0076: public static final String DEFAULT_POOL_MODE = PoolMode.XML_READ_CLASS;
0077:
0078: public static final String DEFAULT_CONDOR_BIN_DIR = "";
0079:
0080: public static final String DEFAULT_CONDOR_CONFIG_DIR = "";
0081:
0082: public static final String DEFAULT_POSTSCRIPT_MODE = "none";
0083:
0084: public static final String POOL_CONFIG_FILE = "sites.";
0085:
0086: public static final String CONDOR_KICKSTART = "kickstart-condor";
0087:
0088: //transfer constants
0089:
0090: public static final String DEFAULT_TRANSFER_IMPLEMENTATION = "Transfer";
0091:
0092: public static final String DEFAULT_TRANSFER_REFINER = "Default";
0093:
0094: public static final String DEFAULT_STAGING_DELIMITER = "-";
0095:
0096: public static final String DEFAULT_TRANSFER_PROCESSES = "4";
0097:
0098: public static final String DEFAULT_TRANSFER_STREAMS = "1";
0099:
0100: //grid start constants
0101: public static final String DEFAULT_GRIDSTART_MODE = "Kickstart";
0102:
0103: public static final String DEFAULT_INVOKE_LENGTH = "4000";
0104:
0105: //site selector constants
0106: public static final String DEFAULT_SITE_SELECTOR = "Random";
0107:
0108: public static final String DEFAULT_SITE_SELECTOR_TIMEOUT = "300";
0109:
0110: public static final String DEFAULT_SITE_SELECTOR_KEEP = "onerror";
0111:
0112: ///some simulator constants that are used
0113: public static final String DEFAULT_DATA_MULTIPLICATION_FACTOR = "1";
0114:
0115: public static final String DEFAULT_COMP_MULTIPLICATION_FACTOR = "1";
0116:
0117: public static final String DEFAULT_COMP_ERROR_PERCENTAGE = "0";
0118:
0119: public static final String DEFAULT_COMP_VARIANCE_PERCENTAGE = "0";
0120:
0121: //collapsing constants
0122: public static final String DEFAULT_JOB_AGGREGATOR = "SeqExec";
0123:
0124: //some tranformation catalog constants
0125: public static final String DEFAULT_TC_MAPPER_MODE = "All";
0126:
0127: public static final String DEFAULT_TX_SELECTOR_MODE = "Random";
0128:
0129: public static final String TC_DATA_FILE = "tc.data";
0130:
0131: //logging constants
0132: public static final String DEFAULT_LOGGING_FILE = "stdout";
0133:
0134: /**
0135: * Default properties that applies priorities to all kinds of transfer
0136: * jobs.
0137: */
0138: public static final String ALL_TRANSFER_PRIORITY_PROPERTY = "pegasus.transfer.*.priority";
0139:
0140: /**
0141: * The default DAXCallback that is loaded, if none is specified by the user.
0142: */
0143: private static final String DEFAULT_DAX_CALLBACK = "DAX2Graph";
0144:
0145: /**
0146: * Ensures only one object is created always. Implements the Singleton.
0147: */
0148: private static PegasusProperties pegProperties = null;
0149:
0150: /**
0151: * The value of the PEGASUS_HOME environment variable.
0152: */
0153: private String mPegasusHome;
0154:
0155: /**
0156: * The object holding all the properties pertaining to the VDS system.
0157: */
0158: private VDSProperties mProps;
0159:
0160: /**
0161: * The Logger object.
0162: */
0163: private LogManager mLogger;
0164:
0165: /**
0166: * The String containing the messages to be logged.
0167: */
0168: private String mLogMsg;
0169:
0170: /**
0171: * The default path to the transformation catalog.
0172: */
0173: private String mDefaultTC;
0174:
0175: /**
0176: * The default path to the pool file.
0177: */
0178: private String mDefaultPoolFile;
0179:
0180: /**
0181: * The default path to the kickstart condor script, that allows the user to
0182: * submit the concrete DAG directly to the underlying CondorG.
0183: */
0184: private String mDefaultCondorKickStart;
0185:
0186: /**
0187: * The default transfer priority that needs to be applied to the transfer
0188: * jobs.
0189: */
0190: private String mDefaultTransferPriority;
0191:
0192: /**
0193: * The set containing the deprecated properties specified by the user.
0194: */
0195: private Set mDeprecatedProperties;
0196:
0197: /**
0198: * The pointer to the properties file that is written out in the submit directory.
0199: */
0200: private String mPropsInSubmitDir;
0201:
0202: /**
0203: * Returns an instance to this properties object.
0204: *
0205: * @return a handle to the Properties class.
0206: */
0207: public static PegasusProperties getInstance() {
0208: return nonSingletonInstance(null);
0209: }
0210:
0211: /**
0212: * Returns an instance to this properties object.
0213: *
0214: * @param propFileName name of the properties file to picked from
0215: * $PEGASUS_HOME/etc/ directory.
0216: *
0217: * @return a handle to the Properties class.
0218: */
0219: public static PegasusProperties getInstance(String propFileName) {
0220: return nonSingletonInstance(propFileName);
0221: }
0222:
0223: /**
0224: * To get a reference to the the object. The properties file that is loaded is
0225: * from the path specified in the argument.
0226: * This is *not implemented* as singleton. However the invocation of this
0227: * does modify the internally held singleton object.
0228: *
0229: * @param propFileName name of the properties file to picked from
0230: * $PEGASUS_HOME/etc/ directory.
0231: *
0232: * @return a handle to the Properties class.
0233: */
0234: protected static PegasusProperties nonSingletonInstance(
0235: String propFileName) {
0236: return new PegasusProperties(propFileName);
0237: }
0238:
0239: /**
0240: * To get a reference to the the object. The properties file that is loaded is
0241: * from the path specified in the argument.
0242: *
0243: * This is *not implemented* as singleton. However the invocation of this
0244: * does modify the internally held singleton object.
0245: *
0246: *
0247: * @return a handle to the Properties class.
0248: */
0249: public static PegasusProperties nonSingletonInstance() {
0250: return nonSingletonInstance(VDSProperties.PROPERTY_FILENAME);
0251: }
0252:
0253: /**
0254: * The constructor that constructs the default paths to the various
0255: * configuration files, and populates the singleton instance as required. If
0256: * the properties file passed is null, then the singleton instance is
0257: * invoked, else the non singleton instance is invoked.
0258: *
0259: * @param propertiesFile name of the properties file to picked
0260: * from $PEGASUS_HOME/etc/ directory.
0261: */
0262: private PegasusProperties(String propertiesFile) {
0263: mLogger = LogManager.getInstance();
0264: mDeprecatedProperties = new HashSet(5);
0265: initializePropertyFile(propertiesFile);
0266: mPegasusHome = mProps.getPegasusHome();
0267:
0268: mDefaultCondorKickStart = getDefaultPathToCondorKickstart();
0269: mDefaultPoolFile = getDefaultPathToSC();
0270: mDefaultTC = getDefaultPathToTC();
0271: mDefaultTransferPriority = getDefaultTransferPriority();
0272:
0273: }
0274:
0275: /**
0276: * Returns the default path to the transformation catalog. Currently the
0277: * default path defaults to $PEGASUS_HOME/var/tc.data.
0278: *
0279: * @return the default path to tc.data.
0280: */
0281: public String getDefaultPathToTC() {
0282: StringBuffer sb = new StringBuffer(50);
0283: sb.append(mPegasusHome);
0284: sb.append(File.separator);
0285: sb.append("var");
0286: File f = new File(sb.toString(), TC_DATA_FILE);
0287:
0288: return f.getAbsolutePath();
0289: }
0290:
0291: /**
0292: * Returns the default path to the site catalog file.
0293: * The default path is constructed on the basis of the mode set by
0294: * the user.
0295: *
0296: * @return $PEGASUS_HOME/etc/sites.txt if the pool mode is Text, else
0297: * $PEGASUS_HOME/etc/sites.xml
0298: *
0299: * @see #getPoolMode()
0300: */
0301: public String getDefaultPathToSC() {
0302: String name = POOL_CONFIG_FILE;
0303: name += (getPoolMode().equalsIgnoreCase("Text")) ? "txt"
0304: : "xml";
0305: File f = new File(mProps.getSysConfDir(), name);
0306: //System.err.println("Default Path to SC is " + f.getAbsolutePath());
0307: return f.getAbsolutePath();
0308: }
0309:
0310: /**
0311: * Returns the default path to the condor kickstart. Currently the path
0312: * defaults to $PEGASUS_HOME/bin/kickstart-condor.
0313: *
0314: * @return default path to kickstart condor.
0315: */
0316: public String getDefaultPathToCondorKickstart() {
0317: StringBuffer sb = new StringBuffer(50);
0318: sb.append(mPegasusHome);
0319: sb.append(File.separator);
0320: sb.append("bin");
0321: sb.append(File.separator);
0322: sb.append(CONDOR_KICKSTART);
0323: return sb.toString();
0324: }
0325:
0326: /**
0327: * Gets the handle to the properties file. The singleton instance is
0328: * invoked if the properties file is null (partly due to the way VDSProperties
0329: * is implemented ), else the non singleton is invoked. If you want to pick
0330: * up the default properties file in a non singleton manner, specify
0331: * VDSProperties.PROPERTY_FILENAME as a parameter.
0332: *
0333: * @param propertiesFile name of the properties file to picked
0334: * from $PEGASUS_HOME/etc/ directory.
0335: */
0336: private void initializePropertyFile(String propertiesFile) {
0337: try {
0338: mProps = (propertiesFile == null) ?
0339: //invoke the singleton instance
0340: VDSProperties.instance()
0341: :
0342: //invoke the non singleton instance
0343: VDSProperties.nonSingletonInstance(propertiesFile);
0344: } catch (IOException e) {
0345: mLogMsg = "unable to read property file: " + e.getMessage();
0346: mLogger.log(mLogMsg, LogManager.FATAL_MESSAGE_LEVEL);
0347: System.exit(1);
0348: } catch (MissingResourceException e) {
0349: mLogMsg = "You forgot to set -Dpegasus.home=$PEGASUS_HOME!";
0350: mLogger.log(mLogMsg, LogManager.FATAL_MESSAGE_LEVEL);
0351: System.exit(1);
0352: }
0353:
0354: }
0355:
0356: /**
0357: * It allows you to get any property from the property file without going
0358: * through the corresponding accesor function in this class. For coding
0359: * and clarity purposes, the function should be used judiciously, and the
0360: * accessor function should be used as far as possible.
0361: *
0362: * @param key the property whose value is desired.
0363: * @return String
0364: */
0365: public String getProperty(String key) {
0366: return mProps.getProperty(key);
0367: }
0368:
0369: /**
0370: * Returns the VDSProperties that this object encapsulates. Use only when
0371: * absolutely necessary. Use accessor methods whereever possible.
0372: *
0373: * @return VDSProperties
0374: */
0375: public VDSProperties getVDSProperties() {
0376: return this .mProps;
0377: }
0378:
0379: /**
0380: * Accessor: Overwrite any properties from within the program.
0381: *
0382: * @param key is the key to look up
0383: * @param value is the new property value to place in the system.
0384: * @return the old value, or null if it didn't exist before.
0385: */
0386: public Object setProperty(String key, String value) {
0387: return mProps.setProperty(key, value);
0388: }
0389:
0390: /**
0391: * Extracts a specific property key subset from the known properties.
0392: * The prefix may be removed from the keys in the resulting dictionary,
0393: * or it may be kept. In the latter case, exact matches on the prefix
0394: * will also be copied into the resulting dictionary.
0395: *
0396: * @param prefix is the key prefix to filter the properties by.
0397: * @param keepPrefix if true, the key prefix is kept in the resulting
0398: * dictionary. As side-effect, a key that matches the prefix exactly
0399: * will also be copied. If false, the resulting dictionary's keys are
0400: * shortened by the prefix. An exact prefix match will not be copied,
0401: * as it would result in an empty string key.
0402: *
0403: * @return a property dictionary matching the filter key. May be
0404: * an empty dictionary, if no prefix matches were found.
0405: *
0406: * @see #getProperty( String ) is used to assemble matches
0407: */
0408: public Properties matchingSubset(String prefix, boolean keepPrefix) {
0409: return mProps.matchingSubset(prefix, keepPrefix);
0410: }
0411:
0412: /**
0413: * Returns the properties matching a particular prefix as a list of
0414: * sorted name value pairs, where name is the full name of the matching
0415: * property (including the prefix) and value is it's value in the properties
0416: * file.
0417: *
0418: * @param prefix the prefix for the property names.
0419: * @param system boolean indicating whether to match only System properties
0420: * or all including the ones in the property file.
0421: *
0422: * @return list of <code>NameValue</code> objects corresponding to the matched
0423: * properties sorted by keys.
0424: * null if no matching property is found.
0425: */
0426: public List getMatchingProperties(String prefix, boolean system) {
0427: //sanity check
0428: if (prefix == null) {
0429: return null;
0430: }
0431: Properties p = (system) ? System.getProperties()
0432: : matchingSubset(prefix, true);
0433:
0434: java.util.Enumeration e = p.propertyNames();
0435: List l = (e.hasMoreElements()) ? new java.util.ArrayList()
0436: : null;
0437:
0438: while (e.hasMoreElements()) {
0439: String key = (String) e.nextElement();
0440: NameValue nv = new NameValue(key, p.getProperty(key));
0441: l.add(nv);
0442: }
0443:
0444: Collections.sort(l);
0445: return (l.isEmpty()) ? null : l;
0446: }
0447:
0448: /**
0449: * Accessor to $PEGASUS_HOME/etc. The files in this directory have a low
0450: * change frequency, are effectively read-only, they reside on a
0451: * per-machine basis, and they are valid usually for a single user.
0452: *
0453: * @return the "etc" directory of the VDS runtime system.
0454: */
0455: public File getSysConfDir() {
0456: return mProps.getSysConfDir();
0457: }
0458:
0459: /**
0460: * Accessor: Obtains the root directory of the Pegasus runtime
0461: * system.
0462: *
0463: * @return the root directory of the Pegasus runtime system, as initially
0464: * set from the system properties.
0465: */
0466: public String getPegasusHome() {
0467: return mProps.getPegasusHome();
0468: }
0469:
0470: //PROPERTIES RELATED TO SCHEMAS
0471: /**
0472: * Returns the location of the schema for the DAX.
0473: *
0474: * Referred to by the "pegasus.schema.dax" property.
0475: *
0476: * @return location to the DAX schema.
0477: */
0478: public String getDAXSchemaLocation() {
0479: return this .getDAXSchemaLocation(null);
0480: }
0481:
0482: /**
0483: * Returns the location of the schema for the DAX.
0484: *
0485: * Referred to by the "pegasus.schema.dax" property.
0486: *
0487: * @param defaultLocation the default location to the schema.
0488: *
0489: * @return location to the DAX schema specified in the properties file,
0490: * else the default location if no value specified.
0491: */
0492: public String getDAXSchemaLocation(String defaultLocation) {
0493: return mProps
0494: .getProperty("pegasus.schema.dax", defaultLocation);
0495: }
0496:
0497: /**
0498: * Returns the location of the schema for the PDAX.
0499: *
0500: * Referred to by the "pegasus.schema.pdax" property
0501: *
0502: * @param defaultLocation the default location to the schema.
0503: *
0504: * @return location to the PDAX schema specified in the properties file,
0505: * else the default location if no value specified.
0506: */
0507: public String getPDAXSchemaLocation(String defaultLocation) {
0508: return mProps.getProperty("pegasus.schema.pdax",
0509: defaultLocation);
0510: }
0511:
0512: //DIRECTORY CREATION PROPERTIES
0513: /**
0514: * Returns the name of the class that the user wants, to insert the
0515: * create directory jobs in the graph in case of creating random
0516: * directories.
0517: *
0518: * Referred to by the "pegasus.dir.create" property.
0519: *
0520: * @return the create dir classname if specified in the properties file,
0521: * else HourGlass.
0522: */
0523: public String getCreateDirClass() {
0524: return mProps.getProperty("pegasus.dir.create", "HourGlass");
0525: }
0526:
0527: /**
0528: * It specifies whether to use the extended timestamp format for generation
0529: * of timestamps that are used to create the random directory name, and for
0530: * the classads generation.
0531: *
0532: * Referred to by the "pegasus.dir.timestamp.extended" property.
0533: *
0534: * @return the value specified in the properties file if valid boolean, else
0535: * false.
0536: */
0537: public boolean useExtendedTimeStamp() {
0538: return Boolean.parse(mProps
0539: .getProperty("pegasus.dir.timestamp.extended"), false);
0540: }
0541:
0542: /**
0543: * Returns a boolean indicating whether to use timestamp for directory
0544: * name creation or not.
0545: *
0546: * Referred to by "pegasus.dir.useTimestamp" property.
0547: *
0548: * @return the boolean value specified in the properties files, else false.
0549: */
0550: public boolean useTimestampForDirectoryStructure() {
0551: return Boolean.parse(mProps
0552: .getProperty("pegasus.dir.useTimestamp"), false);
0553: }
0554:
0555: /**
0556: * Returns the execution directory suffix or absolute specified
0557: * that is appended/replaced to the exec-mount-point specified in the
0558: * pool catalog for the various pools.
0559: *
0560: * Referred to by the "pegasus.dir.exec" property
0561: *
0562: * @return the value specified in the properties file,
0563: * else the default suffix.
0564: *
0565: * @see #DEFAULT_EXEC_DIR
0566: */
0567: public String getExecDirectory() {
0568: return mProps.getProperty("pegasus.dir.exec", DEFAULT_EXEC_DIR);
0569: }
0570:
0571: /**
0572: * Returns the storage directory suffix or absolute specified
0573: * that is appended/replaced to the storage-mount-point specified in the
0574: * pool catalog for the various pools.
0575: *
0576: * Referred to by the "pegasus.dir.storage" property.
0577: *
0578: * @return the value specified in the properties file,
0579: * else the default suffix.
0580: *
0581: * @see #DEFAULT_STORAGE_DIR
0582: */
0583: public String getStorageDirectory() {
0584: return mProps.getProperty("pegasus.dir.storage",
0585: DEFAULT_STORAGE_DIR);
0586: }
0587:
0588: /**
0589: * Returns a boolean indicating whether to have a deep storage directory
0590: * structure or not while staging out data to the output site.
0591: *
0592: * Referred to by the "pegasus.dir.storage.deep" property.
0593: *
0594: * @return the boolean value specified in the properties files, else false.
0595: */
0596: public boolean useDeepStorageDirectoryStructure() {
0597: return Boolean.parse(mProps
0598: .getProperty("pegasus.dir.storage.deep"), false);
0599: }
0600:
0601: //PROPERTIES RELATED TO THE TRANSFORMATION CATALOG
0602: /**
0603: * Returns the mode to be used for accessing the Transformation Catalog.
0604: *
0605: * Referred to by the "pegasus.catalog.transformation" property.
0606: *
0607: * @return the value specified in properties file,
0608: * else DEFAULT_TC_MODE.
0609: *
0610: * @see #DEFAULT_TC_MODE
0611: */
0612: public String getTCMode() {
0613: return mProps.getProperty("pegasus.catalog.transformation",
0614: DEFAULT_TC_MODE);
0615: }
0616:
0617: /**
0618: * Returns the location of the transformation catalog.
0619: *
0620: * Referred to by "pegasus.catalog.transformation.file" property.
0621: *
0622: * @return the value specified in the properties file,
0623: * else default path specified by mDefaultTC.
0624: *
0625: * @see #mDefaultTC
0626: */
0627: public String getTCPath() {
0628: return mProps.getProperty(
0629: "pegasus.catalog.transformation.file", mDefaultTC);
0630: }
0631:
0632: /**
0633: * Returns the mode for loading the transformation mapper that sits in
0634: * front of the transformation catalog.
0635: *
0636: * Referred to by the "pegasus.catalog.transformation.mapper" property.
0637: *
0638: * @return the value specified in the properties file,
0639: * else default tc mapper mode.
0640: *
0641: * @see #DEFAULT_TC_MAPPER_MODE
0642: */
0643: public String getTCMapperMode() {
0644: return mProps.getProperty(
0645: "pegasus.catalog.transformation.mapper",
0646: DEFAULT_TC_MAPPER_MODE);
0647: }
0648:
0649: //REPLICA CATALOG PROPERTIES
0650: /**
0651: * Returns the replica mode. It identifies the ReplicaMechanism being used
0652: * by Pegasus to determine logical file locations.
0653: *
0654: * Referred to by the "pegasus.catalog.replica" property.
0655: *
0656: * @return the replica mode, that is used to load the appropriate
0657: * implementing class if property is specified,
0658: * else the DEFAULT_REPLICA_MODE
0659: *
0660: * @see #DEFAULT_REPLICA_MODE
0661: */
0662: public String getReplicaMode() {
0663: return mProps.getProperty("pegasus.catalog.replica",
0664: DEFAULT_REPLICA_MODE);
0665: }
0666:
0667: /**
0668: * Returns the url to the RLI of the RLS.
0669: *
0670: * Referred to by the "pegasus.rls.url" property.
0671: *
0672: * @return the value specified in properties file,
0673: * else DEFAULT_RLI_URL.
0674: *
0675: * @see #DEFAULT_RLI_URL
0676: */
0677: public String getRLIURL() {
0678: return mProps.getProperty("pegasus.catalog.replica.url",
0679: DEFAULT_RLI_URL);
0680: }
0681:
0682: /**
0683: * It returns the timeout value in seconds after which to timeout in case of
0684: * no activity from the RLS.
0685: *
0686: * Referred to by the "pegasus.rc.rls.timeout" property.
0687: *
0688: * @return the timeout value if specified else,
0689: * DEFAULT_RLS_TIMEOUT.
0690: *
0691: * @see #DEFAULT_RLS_TIMEOUT
0692: */
0693: public int getRLSTimeout() {
0694: String prop = mProps.getProperty(
0695: "pegasus.catalog.replica.rls.timeout",
0696: DEFAULT_RLS_TIMEOUT);
0697: int val;
0698: try {
0699: val = Integer.parseInt(prop);
0700: } catch (Exception e) {
0701: return Integer.parseInt(DEFAULT_RLS_TIMEOUT);
0702: }
0703: return val;
0704:
0705: }
0706:
0707: //PROPERTIES RELATED TO SITE CATALOG
0708: /**
0709: * Returns the mode to be used for accessing the pool information.
0710: *
0711: * Referred to by the "pegasus.catalog.site" property.
0712: *
0713: * @return the pool mode, that is used to load the appropriate
0714: * implementing class if the property is specified,
0715: * else default pool mode specified by DEFAULT_POOL_MODE
0716: *
0717: * @see #DEFAULT_POOL_MODE
0718: */
0719: public String getPoolMode() {
0720: return mProps.getProperty("pegasus.catalog.site",
0721: DEFAULT_POOL_MODE);
0722: }
0723:
0724: /**
0725: * Returns the path to the pool file.
0726: *
0727: * Referred to by the "pegasus.catalog.site.file" property.
0728: *
0729: * @return the path to the pool file specified in the properties file,
0730: * else the default path specified by mDefaultPoolFile.
0731: *
0732: * @see #mDefaultPoolFile
0733: */
0734: public String getPoolFile() {
0735: return mProps.getProperty("pegasus.catalog.site.file",
0736: mDefaultPoolFile);
0737: }
0738:
0739: /**
0740: * Returns the location of the schema for the DAX.
0741: *
0742: * Referred to by the "pegasus.schema.sc" property.
0743: *
0744: * @return the location of pool schema if specified in properties file,
0745: * else null.
0746: */
0747: public String getPoolSchemaLocation() {
0748: return this .getPoolSchemaLocation(null);
0749: }
0750:
0751: /**
0752: * Returns the location of the schema for the site catalog file.
0753: *
0754: * Referred to by the "pegasus.schema.sc" property
0755: *
0756: * @param defaultLocation the default location where the schema should be
0757: * if no other location is specified.
0758: *
0759: * @return the location specified by the property,
0760: * else defaultLocation.
0761: */
0762: public String getPoolSchemaLocation(String defaultLocation) {
0763: return mProps.getProperty("pegasus.schema.sc", defaultLocation);
0764: }
0765:
0766: //PROVENANCE CATALOG PROPERTIES
0767: /**
0768: * Returns the provenance store to use to log the refiner actions.
0769: *
0770: * Referred to by the "pegasus.catalog.provenance.refinement" property.
0771: *
0772: * @return the value set in the properties, else null if not set.
0773: */
0774: public String getRefinementProvenanceStore() {
0775: return mProps
0776: .getProperty("pegasus.catalog.provenance.refinement");
0777: }
0778:
0779: //TRANSFER MECHANISM PROPERTIES
0780:
0781: /**
0782: * Returns the transfer implementation that is to be used for constructing
0783: * the transfer jobs.
0784: *
0785: * Referred to by the "pegasus.transfer.*.impl" property.
0786: *
0787: * @return the transfer implementation, else the
0788: * DEFAULT_TRANSFER_IMPLEMENTATION.
0789: *
0790: * @see #DEFAULT_TRANSFER_IMPLEMENTATION
0791: */
0792: public String getTransferImplementation() {
0793: return getTransferImplementation("pegasus.transfer.*.impl");
0794: }
0795:
0796: /**
0797: * Returns the sls transfer implementation that is to be used for constructing
0798: * the transfer jobs.
0799: *
0800: * Referred to by the "pegasus.transfer.sls.*.impl" property.
0801: *
0802: * @return the transfer implementation, else the
0803: * DEFAULT_TRANSFER_IMPLEMENTATION.
0804: *
0805: * @see #DEFAULT_TRANSFER_IMPLEMENTATION
0806: */
0807: public String getSLSTransferImplementation() {
0808: return getTransferImplementation("pegasus.transfer.sls.*.impl");
0809: }
0810:
0811: /**
0812: * Returns the transfer implementation.
0813: *
0814: * @param property property name.
0815: *
0816: * @return the transfer implementation,
0817: * else the one specified by "pegasus.transfer.*.impl",
0818: * else the DEFAULT_TRANSFER_IMPLEMENTATION.
0819: */
0820: public String getTransferImplementation(String property) {
0821: String value = mProps.getProperty(property,
0822: getDefaultTransferImplementation());
0823:
0824: return (value == null) ? DEFAULT_TRANSFER_IMPLEMENTATION
0825: : value;
0826: }
0827:
0828: /**
0829: * Returns the transfer refiner that is to be used for adding in the
0830: * transfer jobs in the workflow
0831: *
0832: * Referred to by the "pegasus.transfer.refiner" property.
0833: *
0834: * @return the transfer refiner, else the DEFAULT_TRANSFER_REFINER.
0835: *
0836: * @see #DEFAULT_TRANSFER_REFINER
0837: */
0838: public String getTransferRefiner() {
0839: String value = mProps.getProperty("pegasus.transfer.refiner");
0840:
0841: //put in default if still we have a non null
0842: return (value == null) ? DEFAULT_TRANSFER_REFINER : value;
0843:
0844: }
0845:
0846: /**
0847: * Returns whether to introduce quotes around url's before handing to
0848: * g-u-c and condor.
0849: *
0850: * Referred to by "pegasus.transfer.single.quote" property.
0851: *
0852: * @return boolean value specified in the properties file, else
0853: * true in case of non boolean value being specified or property
0854: * not being set.
0855: */
0856: public boolean quoteTransferURL() {
0857: return Boolean.parse(mProps
0858: .getProperty("pegasus.transfer.single.quote"), true);
0859: }
0860:
0861: /**
0862: * It returns the number of processes of g-u-c that the transfer script needs to
0863: * spawn to do the transfers. This is applicable only in the case where the
0864: * transfer executable has the capability of spawning processes. It should
0865: * not be confused with the number of streams that each process opens.
0866: * By default it is set to 4. In case a non integer value is specified in
0867: * the properties file it returns the default value.
0868: *
0869: * Referred to by "pegasus.transfer.throttle.processes" property.
0870: *
0871: * @return the number of processes specified in properties file, else
0872: * DEFAULT_TRANSFER_PROCESSES
0873: *
0874: * @see #DEFAULT_TRANSFER_PROCESSES
0875: */
0876: public String getNumOfTransferProcesses() {
0877: String prop = mProps.getProperty(
0878: "pegasus.transfer.throttle.processes",
0879: DEFAULT_TRANSFER_PROCESSES);
0880: int val = -1;
0881:
0882: try {
0883: val = Integer.parseInt(prop);
0884: } catch (Exception e) {
0885: return DEFAULT_TRANSFER_PROCESSES;
0886: }
0887:
0888: return Integer.toString(val);
0889:
0890: }
0891:
0892: /**
0893: * It returns the number of streams that each transfer process uses to do the
0894: * ftp transfer. By default it is set to 1.In case a non integer
0895: * value is specified in the properties file it returns the default value.
0896: *
0897: * Referred to by "pegasus.transfer.throttle.streams" property.
0898: *
0899: * @return the number of streams specified in the properties file, else
0900: * DEFAULT_TRANSFER_STREAMS.
0901: *
0902: * @see #DEFAULT_TRANSFER_STREAMS
0903: */
0904: public String getNumOfTransferStreams() {
0905:
0906: String prop = mProps.getProperty(
0907: "pegasus.transfer.throttle.streams",
0908: DEFAULT_TRANSFER_STREAMS);
0909: int val = -1;
0910:
0911: try {
0912: val = Integer.parseInt(prop);
0913: } catch (Exception e) {
0914: return DEFAULT_TRANSFER_STREAMS;
0915: }
0916:
0917: return Integer.toString(val);
0918:
0919: }
0920:
0921: /**
0922: * It specifies whether the underlying transfer mechanism being used should
0923: * use the force option if available to transfer the files.
0924: *
0925: * Referred to by "pegasus.transfer.force" property.
0926: *
0927: * @return boolean value specified in the properties file,else
0928: * false in case of non boolean value being specified or
0929: * property not being set.
0930: */
0931: public boolean useForceInTransfer() {
0932: return Boolean.parse(mProps
0933: .getProperty("pegasus.transfer.force"), false);
0934: }
0935:
0936: /**
0937: * It returns whether the use of symbolic links in case where the source
0938: * and destination files happen to be on the same file system.
0939: *
0940: * Referred to by "pegasus.transfer.links" property.
0941: *
0942: * @return boolean value specified in the properties file, else
0943: * false in case of non boolean value being specified or
0944: * property not being set.
0945: */
0946: public boolean getUseOfSymbolicLinks() {
0947: String value = mProps.getProperty("pegasus.transfer.links");
0948: return Boolean.parse(value, false);
0949: }
0950:
0951: /**
0952: * Returns the comma separated list of third party sites, specified in the
0953: * properties.
0954: *
0955: * @param property property name.
0956: *
0957: * @return the comma separated list of sites.
0958: */
0959: public String getThirdPartySites(String property) {
0960: String value = mProps.getProperty(property);
0961:
0962: return value;
0963:
0964: }
0965:
0966: /**
0967: * Returns the comma separated list of third party sites for which
0968: * the third party transfers are executed on the remote sites.
0969: *
0970: *
0971: * @param property property name.
0972: *
0973: * @return the comma separated list of sites.
0974: */
0975: public String getThirdPartySitesRemote(String property) {
0976: return mProps.getProperty(property);
0977: }
0978:
0979: /**
0980: * Returns the delimiter to be used for constructing the staged executable
0981: * name, during transfer of executables to remote sites.
0982: *
0983: * Referred to by the "pegasus.transfer.staging.delimiter" property.
0984: *
0985: * @return the value specified in the properties file, else
0986: * DEFAULT_STAGING_DELIMITER
0987: *
0988: * @see #DEFAULT_STAGING_DELIMITER
0989: */
0990: public String getStagingDelimiter() {
0991: return mProps.getProperty("pegasus.transfer.staging.delimiter",
0992: DEFAULT_STAGING_DELIMITER);
0993: }
0994:
0995: /**
0996: * Returns the list of sites for which the chmod job creation has to be
0997: * disabled for executable staging.
0998: *
0999: * Referred to by the "pegasus.transfer.disable.chmod" property.
1000: *
1001: * @return a comma separated list of site names.
1002: */
1003: public String getChmodDisabledSites() {
1004: return mProps
1005: .getProperty("pegasus.transfer.disable.chmod.sites");
1006: }
1007:
1008: /**
1009: * It specifies if for a job execution the proxy is to be transferred
1010: * from the submit host or not.
1011: *
1012: * Referred to by "pegasus.transfer.proxy" property.
1013: *
1014: * @return boolean value specified in the properties file,else
1015: * false in case of non boolean value being specified or
1016: * property not being set.
1017: */
1018: public boolean transferProxy() {
1019: return Boolean.parse(mProps
1020: .getProperty("pegasus.transfer.proxy"), false);
1021: }
1022:
1023: /**
1024: * Returns the arguments with which the transfer executable needs
1025: * to be invoked.
1026: *
1027: * Referred to by "pegasus.transfer.arguments" property.
1028: *
1029: * @return the arguments specified in the properties file,
1030: * else null if property is not specified.
1031: */
1032: public String getTransferArguments() {
1033: return mProps.getProperty("pegasus.transfer.arguments");
1034: }
1035:
1036: /**
1037: * Returns the priority to be set for the stage in transfer job.
1038: *
1039: * Referred to by "pegasus.transfer.stagein.priority" property if set,
1040: * else by "pegasus.transfer.*.priority" property.
1041: *
1042: * @return the priority as String if a valid integer specified in the
1043: * properties, else null.
1044: */
1045: public String getTransferStageInPriority() {
1046: return getTransferPriority("pegasus.transfer.stagein.priority");
1047: }
1048:
1049: /**
1050: * Returns the priority to be set for the stage out transfer job.
1051: *
1052: * Referred to by "pegasus.transfer.stageout.priority" property if set,
1053: * else by "pegasus.transfer.*.priority" property.
1054: *
1055: * @return the priority as String if a valid integer specified in the
1056: * properties, else null.
1057: */
1058: public String getTransferStageOutPriority() {
1059: return getTransferPriority("pegasus.transfer.stageout.priority");
1060: }
1061:
1062: /**
1063: * Returns the priority to be set for the interpool transfer job.
1064: *
1065: * Referred to by "pegasus.transfer.inter.priority" property if set,
1066: * else by "pegasus.transfer.*.priority" property.
1067: *
1068: * @return the priority as String if a valid integer specified in the
1069: * properties, else null.
1070: */
1071: public String getTransferInterPriority() {
1072: return getTransferPriority("pegasus.transfer.inter.priority");
1073: }
1074:
1075: /**
1076: * Returns the transfer priority.
1077: *
1078: * @param property property name.
1079: *
1080: * @return the priority as String if a valid integer specified in the
1081: * properties as value to property, else null.
1082: */
1083: private String getTransferPriority(String property) {
1084: String value = mProps.getProperty(property,
1085: mDefaultTransferPriority);
1086: int val = -1;
1087: try {
1088: val = Integer.parseInt(value);
1089: } catch (Exception e) {
1090:
1091: }
1092: //if value in properties file is corrupted
1093: //again use the default transfer priority
1094: return (val < 0) ? mDefaultTransferPriority : Integer
1095: .toString(val);
1096:
1097: }
1098:
1099: //REPLICA SELECTOR FUNCTIONS
1100:
1101: /**
1102: * Returns the mode for loading the transformation selector that selects
1103: * amongst the various candidate transformation catalog entry objects.
1104: *
1105: * Referred to by the "pegasus.selector.transformation" property.
1106: *
1107: * @return the value specified in the properties file,
1108: * else default transformation selector.
1109: *
1110: * @see #DEFAULT_TC_MAPPER_MODE
1111: */
1112: public String getTXSelectorMode() {
1113: return mProps.getProperty("pegasus.selector.transformation",
1114: DEFAULT_TX_SELECTOR_MODE);
1115: }
1116:
1117: /**
1118: * Returns the name of the selector to be used for selection amongst the
1119: * various replicas of a single lfn.
1120: *
1121: * Referred to by the "pegasus.selector.replica" property.
1122: *
1123: * @return the name of the selector if the property is specified,
1124: * else null
1125: */
1126: public String getReplicaSelector() {
1127: return mProps.getProperty("pegasus.selector.replica");
1128: }
1129:
1130: /**
1131: * Returns a comma separated list of sites, that are restricted in terms of
1132: * data movement from the site.
1133: *
1134: * Referred to by the "pegasus.rc.restricted.sites" property.
1135: *
1136: * @return comma separated list of sites.
1137: */
1138: // public String getRestrictedSites(){
1139: // return mProps.getProperty("pegasus.rc.restricted.sites","");
1140: // }
1141: /**
1142: * Returns a comma separated list of sites, from which to prefer data
1143: * transfers for all sites.
1144: *
1145: * Referred to by the "pegasus.selector.replica.*.prefer.stagein.sites" property.
1146: *
1147: * @return comma separated list of sites.
1148: */
1149: public String getAllPreferredSites() {
1150: return mProps.getProperty(
1151: "pegasus.selector.replica.*.prefer.stagein.sites", "");
1152: }
1153:
1154: /**
1155: * Returns a comma separated list of sites, from which to ignore data
1156: * transfers for all sites. Replaces the old pegasus.rc.restricted.sites
1157: * property.
1158: *
1159: * Referred to by the "pegasus.selector.ignore.*.prefer.stagein.sites" property.
1160: *
1161: * @return comma separated list of sites.
1162: */
1163: public String getAllIgnoredSites() {
1164: return mProps.getProperty(
1165: "pegasus.selector.replica.*.ignore.stagein.sites", "");
1166: }
1167:
1168: //SITE SELECTOR PROPERTIES
1169: /**
1170: * Returns the class name of the site selector, that needs to be invoked to do
1171: * the site selection.
1172: *
1173: * Referred to by the "pegasus.selector.site" property.
1174: *
1175: * @return the classname corresponding to the site selector that needs to be
1176: * invoked if specified in the properties file, else the default
1177: * selector specified by DEFAULT_SITE_SELECTOR.
1178: *
1179: * @see #DEFAULT_SITE_SELECTOR
1180: */
1181: public String getSiteSelectorMode() {
1182: return mProps.getProperty("pegasus.selector.site",
1183: DEFAULT_SITE_SELECTOR);
1184: }
1185:
1186: /**
1187: * Returns the path to the external site selector that needs to be called
1188: * out to make the decision of site selection.
1189: *
1190: * Referred to by the "pegasus.selector.site.path" property.
1191: *
1192: * @return the path to the external site selector if specified in the
1193: * properties file, else null.
1194: */
1195: public String getSiteSelectorPath() {
1196: return mProps.getProperty("pegasus.selector.site.path");
1197: }
1198:
1199: /**
1200: * It returns the timeout value in seconds after which to timeout in case of
1201: * no activity from the external site selector.
1202: *
1203: * Referred to by the "pegasus.selector.site.timeout" property.
1204: *
1205: * @return the timeout value if specified else,
1206: * DEFAULT_SITE_SELECTOR_TIMEOUT.
1207: *
1208: * @see #DEFAULT_SITE_SELECTOR_TIMEOUT
1209: */
1210: public int getSiteSelectorTimeout() {
1211: String prop = mProps.getProperty(
1212: "pegasus.selector.site.timeout",
1213: DEFAULT_SITE_SELECTOR_TIMEOUT);
1214: int val;
1215: try {
1216: val = Integer.parseInt(prop);
1217: } catch (Exception e) {
1218: return Integer.parseInt(DEFAULT_SITE_SELECTOR_TIMEOUT);
1219: }
1220: return val;
1221:
1222: }
1223:
1224: /**
1225: * Returns a value designating whether we need to keep the temporary files
1226: * that are passed to the external site selectors. The check for the valid
1227: * tristate value should be done at the calling function end. This just
1228: * passes on the value user specified in the properties file.
1229: *
1230: * Referred to by the "pegasus.selector.site.keep.tmp" property.
1231: *
1232: * @return the value of the property is specified, else
1233: * DEFAULT_SITE_SELECTOR_KEEP
1234: *
1235: * @see #DEFAULT_SITE_SELECTOR_KEEP
1236: */
1237: public String getSiteSelectorKeep() {
1238: return mProps.getProperty("pegasus.selector.site.keep.tmp",
1239: DEFAULT_SITE_SELECTOR_KEEP);
1240: }
1241:
1242: //PROPERTIES RELATED TO KICKSTART AND EXITCODE
1243:
1244: /**
1245: * Returns the GRIDSTART that is to be used to launch the jobs on the grid.
1246: *
1247: * Referred to by the "pegasus.gridstart" property.
1248: *
1249: * @return the value specified in the property file,
1250: * else DEFAULT_GRIDSTART_MODE
1251: *
1252: * @see #DEFAULT_GRIDSTART_MODE
1253: */
1254: public String getGridStart() {
1255: return mProps.getProperty("pegasus.gridstart",
1256: DEFAULT_GRIDSTART_MODE);
1257: }
1258:
1259: /**
1260: * Return a boolean indicating whether to turn the stat option for kickstart
1261: * on or not. By default it is turned on.
1262: *
1263: * Referred to by the "pegasus.gridstart.kickstart.stat" property.
1264: *
1265: * @return the boolean value specified in the property file,
1266: * else false if not specified or non boolean specified.
1267: */
1268: public boolean doStatWithKickstart() {
1269: return Boolean
1270: .parse(
1271: mProps
1272: .getProperty("pegasus.gridstart.kickstart.stat"),
1273: false);
1274: }
1275:
1276: /**
1277: * Return a boolean indicating whether to generate the LOF files for the jobs
1278: * or not. This is used to generate LOF files, but not trigger the stat option
1279: *
1280: * Referred to by the "pegasus.gridstart.kickstart.generate.loft" property.
1281: *
1282: * @return the boolean value specified in the property file,
1283: * else false if not specified or non boolean specified.
1284: */
1285: public boolean generateLOFFiles() {
1286: return Boolean.parse(mProps
1287: .getProperty("pegasus.gridstart.generate.lof"), false);
1288: }
1289:
1290: /**
1291: * Returns a boolean indicating whether to use invoke in kickstart always
1292: * or not.
1293: *
1294: * Referred to by the "pegasus.gridstart.invoke.always" property.
1295: *
1296: * @return the boolean value specified in the property file,
1297: * else false if not specified or non boolean specified.
1298: */
1299: public boolean useInvokeInGridStart() {
1300: return Boolean.parse(mProps
1301: .getProperty("pegasus.gridstart.invoke.always"), false);
1302: }
1303:
1304: /**
1305: * Returns the trigger value for invoking an application through kickstart
1306: * using kickstart. If the arguments value being constructed in the condor
1307: * submit file is more than this value, then invoke is used to pass the
1308: * arguments to the remote end. Helps in bypassing the Condor 4K limit.
1309: *
1310: * Referred to by "pegasus.gridstart.invoke.length" property.
1311: *
1312: * @return the long value specified in the properties files, else
1313: * DEFAULT_INVOKE_LENGTH
1314: *
1315: * @see #DEFAULT_INVOKE_LENGTH
1316: */
1317: public long getGridStartInvokeLength() {
1318: long value = new Long(this .DEFAULT_INVOKE_LENGTH).longValue();
1319:
1320: String st = mProps.getProperty(
1321: "pegasus.gridstart.invoke.length",
1322: this .DEFAULT_INVOKE_LENGTH);
1323: try {
1324: value = new Long(st).longValue();
1325: } catch (Exception e) {
1326: //ignore malformed values from
1327: //the property file
1328: }
1329:
1330: return value;
1331: }
1332:
1333: /**
1334: * Returns a boolean indicating whehter to pass extra options to kickstart
1335: * or not. The extra options have appeared only in VDS version 1.4.2 (like -L
1336: * and -T).
1337: *
1338: * Referred to by "pegasus.gridstart.label" property.
1339: *
1340: * @return the boolean value specified in the property file,
1341: * else false if not specified or non boolean specified.
1342: */
1343: public boolean generateKickstartExtraOptions() {
1344: return Boolean.parse(mProps
1345: .getProperty("pegasus.gridstart.label"), false);
1346: }
1347:
1348: /**
1349: * Returns the mode adding the postscripts for the jobs. At present takes in
1350: * only two values all or none default being none.
1351: *
1352: * Referred to by the "pegasus.exitcode.scope" property.
1353: *
1354: * @return the mode specified by the property, else
1355: * DEFAULT_POSTSCRIPT_MODE
1356: *
1357: * @see #DEFAULT_POSTSCRIPT_MODE
1358: */
1359: public String getPOSTScriptScope() {
1360: return mProps.getProperty("pegasus.exitcode.scope",
1361: DEFAULT_POSTSCRIPT_MODE);
1362: }
1363:
1364: /**
1365: * Returns the postscript to use with the jobs in the workflow. They
1366: * maybe overriden by values specified in the profiles.
1367: *
1368: * Referred to by the "pegasus.exitcode.impl" property.
1369: *
1370: * @return the postscript to use for the workflow, else null if not
1371: * specified in the properties.
1372: */
1373: public String getPOSTScript() {
1374: return mProps.getProperty("pegasus.exitcode.impl");
1375: }
1376:
1377: /**
1378: * Returns the path to the exitcode executable to be used.
1379: *
1380: * Referred to by the "pegasus.exitcode.path.[value]" property, where [value]
1381: * is replaced by the value passed an input to this function.
1382: *
1383: * @param value the short name of the postscript whose path we want.
1384: *
1385: * @return the path to the postscript if specified in properties file.
1386: */
1387: public String getPOSTScriptPath(String value) {
1388: value = (value == null) ? "*" : value;
1389: StringBuffer key = new StringBuffer();
1390: key.append("pegasus.exitcode.path.").append(value);
1391:
1392: return mProps.getProperty(key.toString());
1393: }
1394:
1395: /**
1396: * Returns the argument string containing the arguments by which exitcode is
1397: * invoked.
1398: *
1399: * Referred to by the "pegasus.exitcode.arguments" property.
1400: *
1401: * @return String containing the arguments,else empty string.
1402: */
1403: public String getPOSTScriptArguments() {
1404: return mProps.getProperty("pegasus.exitcode.arguments", "");
1405: }
1406:
1407: /**
1408: * Returns a boolean indicating whether to turn debug on or not for exitcode.
1409: * By default false is returned.
1410: *
1411: * Referred to by the "pegasus.exitcode.debug" property.
1412: *
1413: * @return boolean value.
1414: */
1415: public boolean setPostSCRIPTDebugON() {
1416: return Boolean.parse(mProps
1417: .getProperty("pegasus.exitcode.debug"), false);
1418: }
1419:
1420: /**
1421: * Returns the argument string containing the arguments by which prescript is
1422: * invoked.
1423: *
1424: * Referred to by the "pegasus.prescript.arguments" property.
1425: *
1426: * @return String containing the arguments.
1427: * null if not specified.
1428: */
1429: public String getPrescriptArguments() {
1430: return mProps.getProperty("pegasus.prescript.arguments", "");
1431: }
1432:
1433: //PROPERTIES RELATED TO REMOTE SCHEDULERS
1434: /**
1435: * Returns the project names that need to be appended to the RSL String
1436: * while creating the submit files. Referred to by
1437: * pegasus.remote.projects property. If present, Pegasus ends up
1438: * inserting an RSL string (project = value) in the submit file.
1439: *
1440: * @return a comma separated list of key value pairs if property specified,
1441: * else null.
1442: */
1443: public String getRemoteSchedulerProjects() {
1444: return mProps.getProperty("pegasus.remote.scheduler.projects");
1445: }
1446:
1447: /**
1448: * Returns the queue names that need to be appended to the RSL String while
1449: * creating the submit files. Referred to by the pegasus.remote.queues
1450: * property. If present, Pegasus ends up inserting an RSL string
1451: * (project = value) in the submit file.
1452: *
1453: * @return a comma separated list of key value pairs if property specified,
1454: * else null.
1455: */
1456: public String getRemoteSchedulerQueues() {
1457: return mProps.getProperty("pegasus.remote.scheduler.queues");
1458: }
1459:
1460: /**
1461: * Returns the maxwalltimes for the various pools that need to be appended
1462: * to the RSL String while creating the submit files. Referred to by the
1463: * pegasus.scheduler.remote.queues property. If present, Pegasus ends up
1464: * inserting an RSL string (project = value) in the submit file.
1465: *
1466: *
1467: * @return a comma separated list of key value pairs if property specified,
1468: * else null.
1469: */
1470: public String getRemoteSchedulerMaxWallTimes() {
1471: return mProps
1472: .getProperty("pegasus.remote.scheduler.min.maxwalltime");
1473: }
1474:
1475: /**
1476: * Returns the minimum walltimes that need to be enforced.
1477: *
1478: * Referred to by "pegasus.scheduler.remote.min.[key]" property.
1479: *
1480: * @param key the appropriate globus RSL key. Generally are
1481: * maxtime|maxwalltime|maxcputime
1482: *
1483: * @return the integer value as specified, -1 in case of no value being specified.
1484: */
1485: public int getMinimumRemoteSchedulerTime(String key) {
1486: StringBuffer property = new StringBuffer();
1487: property.append("pegasus.remote.scheduler.min.").append(key);
1488:
1489: int val = -1;
1490:
1491: try {
1492: val = Integer.parseInt(mProps.getProperty(property
1493: .toString()));
1494: } catch (Exception e) {
1495: }
1496: return val;
1497: }
1498:
1499: //PROPERTIES RELATED TO CONDOR
1500:
1501: /**
1502: * Returns a boolean indicating whether we want to Condor Quote the
1503: * arguments of the job or not.
1504: *
1505: * Referred to by the "pegasus.condor.arguments.quote" property.
1506: *
1507: * @return boolean
1508: */
1509: public boolean useCondorQuotingForArguments() {
1510: return Boolean.parse(mProps
1511: .getProperty("pegasus.condor.arguments.quote"), true);
1512: }
1513:
1514: /**
1515: * Returns the number of release attempts that are written into the condor
1516: * submit files. Condor holds jobs on certain kind of failures, which many
1517: * a time are transient, and if a job is released it usually progresses.
1518: *
1519: * Referred to by the "pegasus.condor.release" property.
1520: *
1521: * @return an int denoting the number of times to release.
1522: * null if not specified or invalid entry.
1523: */
1524: public String getCondorPeriodicReleaseValue() {
1525: String prop = mProps.getProperty("pegasus.condor.release");
1526: int val = -1;
1527:
1528: try {
1529: val = Integer.parseInt(prop);
1530: } catch (Exception e) {
1531: return null;
1532: }
1533:
1534: return (val < 0) ? null : Integer.toString(val);
1535: }
1536:
1537: /**
1538: * Returns the number of release attempts that are attempted before
1539: * Condor removes the job from the queue and marks it as failed.
1540: *
1541: * Referred to by the "pegasus.condor.remove" property.
1542: *
1543: * @return an int denoting the number of times to release.
1544: * null if not specified or invalid entry.
1545: */
1546: public String getCondorPeriodicRemoveValue() {
1547: String prop = mProps.getProperty("pegasus.condor.remove");
1548: int val = -1;
1549:
1550: try {
1551: val = Integer.parseInt(prop);
1552: } catch (Exception e) {
1553: return null;
1554: }
1555:
1556: return (val < 0) ? null : Integer.toString(val);
1557: }
1558:
1559: /**
1560: * Returns the number of times Condor should retry running a job in case
1561: * of failure. The retry ends up reinvoking the prescript, that can change
1562: * the site selection decision in case of failure.
1563: *
1564: * Referred to by the "pegasus.dagman.retry" property.
1565: *
1566: * @return an int denoting the number of times to retry.
1567: * null if not specified or invalid entry.
1568: */
1569: public String getCondorRetryValue() {
1570: String prop = mProps.getProperty("pegasus.dagman.retry");
1571: int val = -1;
1572:
1573: try {
1574: val = Integer.parseInt(prop);
1575: } catch (Exception e) {
1576: return null;
1577: }
1578:
1579: return Integer.toString(val);
1580: }
1581:
1582: /**
1583: * Tells whether to stream condor output or not. By default it is true ,
1584: * meaning condor streams the output from the remote hosts back to the submit
1585: * hosts, instead of staging it. This helps in saving filedescriptors at the
1586: * jobmanager end.
1587: *
1588: * If it is set to false, output is not streamed back. The line
1589: * "stream_output = false" should be added in the submit files for kickstart
1590: * jobs.
1591: *
1592: * Referred to by the "pegasus.condor.output.stream" property.
1593: *
1594: * @return the boolean value specified by the property, else
1595: * true in case of invalid value or property not being specified.
1596: *
1597: */
1598: public boolean streamCondorOutput() {
1599: return Boolean.parse(mProps
1600: .getProperty("pegasus.condor.output.stream"), true);
1601: }
1602:
1603: /**
1604: * Tells whether to stream condor error or not. By default it is true ,
1605: * meaning condor streams the error from the remote hosts back to the submit
1606: * hosts instead of staging it in. This helps in saving filedescriptors at
1607: * the jobmanager end.
1608: *
1609: * Referred to by the "pegasus.condor.error.stream" property.
1610: *
1611: * If it is set to false, output is not streamed back. The line
1612: * "stream_output = false" should be added in the submit files for kickstart
1613: * jobs.
1614: *
1615: * @return the boolean value specified by the property, else
1616: * true in case of invalid value or property not being specified.
1617: */
1618: public boolean streamCondorError() {
1619: return Boolean.parse(mProps
1620: .getProperty("pegasus.condor.error.stream"), true);
1621: }
1622:
1623: //PROPERTIES RELATED TO STORK
1624: /**
1625: * Returns the credential name to be used for the stork transfer jobs.
1626: *
1627: * Referred to by the "pegasus.transfer.stork.cred" property.
1628: *
1629: * @return the credential name if specified by the property,
1630: * else null.
1631: */
1632: public String getCredName() {
1633: return mProps.getProperty("pegasus.transfer.stork.cred");
1634: }
1635:
1636: //SOME LOGGING PROPERTIES
1637: /**
1638: * Returns the file to which all the logging needs to be directed to.
1639: *
1640: * Referred to by the "pegasus.log.*" property.
1641: *
1642: * @return the value of the property that is specified, else
1643: * null
1644: */
1645: public String getLoggingFile() {
1646: return mProps.getProperty("pegasus.log.*");
1647: }
1648:
1649: /**
1650: * Returns the location of the local log file where you want the messages to
1651: * be logged. Not used for the moment.
1652: *
1653: * Referred to by the "pegasus.log4j.log" property.
1654: *
1655: * @return the value specified in the property file,else null.
1656: */
1657: public String getLog4JLogFile() {
1658: return mProps.getProperty("pegasus.log4j.log");
1659: }
1660:
1661: /**
1662: * Return returns the environment string specified for the local pool. If
1663: * specified the registration jobs are set with these environment variables.
1664: *
1665: * Referred to by the "pegasus.local.env" property
1666: *
1667: * @return the environment string for local pool in properties file if
1668: * defined, else null.
1669: */
1670: public String getLocalPoolEnvVar() {
1671: return mProps.getProperty("pegasus.local.env");
1672: }
1673:
1674: /**
1675: * Returns a boolean indicating whether to write out the planner metrics
1676: * or not.
1677: *
1678: * Referred to by the "pegasus.log.metrics" property.
1679: *
1680: * @return boolean in the properties, else true
1681: */
1682: public boolean writeOutMetrics() {
1683: return Boolean.parse(mProps.getProperty("pegasus.log.metrics"),
1684: true);
1685: }
1686:
1687: /**
1688: * Returns the path to the file that is used to be logging metrics
1689: *
1690: * Referred to by the "pegasus.log.metrics.file" property.
1691: *
1692: * @return path to the metrics file if specified, else $PEGASUS_HOME/var/pegasus.log
1693: */
1694: public String getMetricsLogFile() {
1695: String file = mProps.getProperty("pegasus.log.metrics.file");
1696: if (file == null || file.length() == 0) {
1697: //construct the default path
1698: File dir = new File(this .getPegasusHome(), "var");
1699: file = new File(dir, "pegasus.log").getAbsolutePath();
1700: }
1701: return file;
1702: }
1703:
1704: //SOME MISCELLANEOUS PROPERTIES
1705:
1706: /**
1707: * Returns a boolean indicating whether to have jobs executing on worker
1708: * node tmp or not.
1709: *
1710: * Referred to by the "pegasus.execute.*.filesystem.local" property.
1711: *
1712: * @return boolean value in the properties file, else false if not specified
1713: * or an invalid value specified.
1714: */
1715: public boolean executeOnWorkerNode() {
1716: return Boolean.parse(mProps
1717: .getProperty("pegasus.execute.*.filesystem.local"),
1718: false);
1719: }
1720:
1721: /**
1722: * Returns a boolean indicating whether to treat the entries in the cache
1723: * files as a replica catalog or not.
1724: *
1725: * @return boolean
1726: */
1727: public boolean treatCacheAsRC() {
1728: return Boolean.parse(mProps
1729: .getProperty("pegasus.catalog.replica.cache.asrc"),
1730: false);
1731: }
1732:
1733: /**
1734: * Returns the timeout value in seconds after which to timeout in case of
1735: * opening sockets to grid ftp server.
1736: *
1737: * Referred to by the "pegasus.auth.gridftp.timeout" property.
1738: *
1739: * @return the timeout value if specified else,
1740: * null.
1741: *
1742: * @see #DEFAULT_SITE_SELECTOR_TIMEOUT
1743: */
1744: public String getGridFTPTimeout() {
1745: return mProps.getProperty("pegasus.auth.gridftp.timeout");
1746: }
1747:
1748: /**
1749: * Returns which submit mode to be used to submit the jobs on to the grid.
1750: *
1751: * Referred to by the "pegasus.submit" property.
1752: *
1753: * @return the submit mode specified in the property file,
1754: * else the default i.e condor.
1755: */
1756: public String getSubmitMode() {
1757: return mProps.getProperty("pegasus.submit", "condor");
1758: }
1759:
1760: /**
1761: * Returns the mode for parsing the dax while writing out the partitioned
1762: * daxes.
1763: *
1764: * Referred to by the "pegasus.partition.parser.load" property.
1765: *
1766: * @return the value specified in the properties file, else
1767: * the default value i.e single.
1768: */
1769: public String getPartitionParsingMode() {
1770: return mProps.getProperty("pegasus.partition.parser.load",
1771: "single");
1772: }
1773:
1774: /**
1775: * Returns the default priority that needs to be applied to all job.
1776: *
1777: * Referred to by the "pegasus.job.priority" property.
1778: *
1779: * @return the value specified in the properties file, null if a non
1780: * integer value is passed.
1781: */
1782: public String getJobPriority() {
1783: String prop = mProps.getProperty("pegasus.job.priority");
1784: int val = -1;
1785:
1786: try {
1787: val = Integer.parseInt(prop);
1788: } catch (Exception e) {
1789: return null;
1790: }
1791:
1792: return (val < 0) ? null : Integer.toString(val);
1793:
1794: }
1795:
1796: //JOB COLLAPSING PROPERTIES
1797:
1798: /**
1799: * Returns a comma separated list for the node collapsing criteria for the
1800: * execution pools. This determines how many jobs one fat node gobbles up.
1801: *
1802: * Referred to by the "pegasus.cluster.nodes" property.
1803: *
1804: * @return the value specified in the properties file, else null.
1805: */
1806: public String getCollapseFactors() {
1807: return mProps.getProperty("pegasus.clusterer.nodes");
1808: }
1809:
1810: /**
1811: * Returns what job aggregator is to be used to aggregate multiple
1812: * compute jobs into a single condor job.
1813: *
1814: * Referred to by the "pegasus.cluster.job.aggregator" property.
1815: *
1816: * @return the value specified in the properties file, else
1817: * DEFAULT_JOB_AGGREGATOR
1818: *
1819: * @see #DEFAULT_JOB_AGGREGATOR
1820: */
1821: public String getJobAggregator() {
1822: return mProps.getProperty("pegasus.clusterer.job.aggregator",
1823: DEFAULT_JOB_AGGREGATOR);
1824: }
1825:
1826: /**
1827: * Returns what job aggregator is to be used to aggregate multiple
1828: * compute jobs into a single condor job.
1829: *
1830: * Referred to by the "pegasus.cluster.job.aggregator.seqexec.log.global" property.
1831: *
1832: * @return the value specified in the properties file, else
1833: * DEFAULT_JOB_AGGREGATOR
1834: *
1835: * @see #DEFAULT_JOB_AGGREGATOR
1836: */
1837: public boolean jobAggregatorLogGlobal() {
1838: return Boolean
1839: .parse(
1840: mProps
1841: .getProperty("pegasus.clusterer.job.aggregator.seqexec.hasgloballog"),
1842: true);
1843: }
1844:
1845: //DEFERRED PLANNING PROPERTIES
1846: /**
1847: * Returns the DAXCallback that is to be used while parsing the DAX.
1848: *
1849: * Referred to by the "pegasus.parser.dax.callback" property.
1850: *
1851: * @return the value specified in the properties file, else
1852: * DEFAULT_DAX_CALLBACK
1853: *
1854: * @see #DEFAULT_DAX_CALLBACK
1855: */
1856: public String getDAXCallback() {
1857: return mProps.getProperty("pegasus.parser.dax.callback",
1858: DEFAULT_DAX_CALLBACK);
1859: }
1860:
1861: /**
1862: * Returns the key that is to be used as a label key, for labelled
1863: * partitioning.
1864: *
1865: * Referred to by the "pegasus.partitioner.label.key" property.
1866: *
1867: * @return the value specified in the properties file.
1868: */
1869: public String getPartitionerLabelKey() {
1870: return mProps.getProperty("pegasus.partitioner.label.key");
1871: }
1872:
1873: /**
1874: * Returns the bundle value for a particular transformation.
1875: *
1876: * Referred to by the "pegasus.partitioner.horziontal.bundle.[txname]" property,
1877: * where [txname] is replaced by the name passed an input to this function.
1878: *
1879: * @param name the logical name of the transformation.
1880: *
1881: * @return the path to the postscript if specified in properties file,
1882: * else null.
1883: */
1884: public String getHorizontalPartitionerBundleValue(String name) {
1885: StringBuffer key = new StringBuffer();
1886: key.append("pegasus.partitioner.horizontal.bundle.").append(
1887: name);
1888: return mProps.getProperty(key.toString());
1889: }
1890:
1891: /**
1892: * Returns the collapse value for a particular transformation.
1893: *
1894: * Referred to by the "pegasus.partitioner.horziontal.collapse.[txname]" property,
1895: * where [txname] is replaced by the name passed an input to this function.
1896: *
1897: * @param name the logical name of the transformation.
1898: *
1899: * @return the path to the postscript if specified in properties file,
1900: * else null.
1901: */
1902: public String getHorizontalPartitionerCollapseValue(String name) {
1903: StringBuffer key = new StringBuffer();
1904: key.append("pegasus.partitioner.horizontal.collapse.").append(
1905: name);
1906: return mProps.getProperty(key.toString());
1907: }
1908:
1909: /**
1910: * Returns the key that is to be used as a label key, for labelled
1911: * clustering.
1912: *
1913: * Referred to by the "pegasus.clusterer.label.key" property.
1914: *
1915: * @return the value specified in the properties file.
1916: */
1917: public String getClustererLabelKey() {
1918: return mProps.getProperty("pegasus.clusterer.label.key");
1919: }
1920:
1921: /**
1922: * Returns the path to the property file that has been writting out in
1923: * the submit directory.
1924: *
1925: * @return path to the property file
1926: *
1927: * @exception RuntimeException in case of file not being generated.
1928: */
1929: public String getPropertiesInSubmitDirectory() {
1930: if (mPropsInSubmitDir == null
1931: || mPropsInSubmitDir.length() == 0) {
1932: throw new RuntimeException(
1933: "Properties file does not exist in directory ");
1934: }
1935: return mPropsInSubmitDir;
1936: }
1937:
1938: /**
1939: * Writes out the properties to a temporary file in the directory passed.
1940: *
1941: * @param directory the directory in which the properties file needs to
1942: * be written to.
1943: *
1944: * @return the absolute path to the properties file written in the directory.
1945: *
1946: * @throws IOException in case of error while writing out file.
1947: */
1948: public String writeOutProperties(String directory)
1949: throws IOException {
1950: File dir = new File(directory);
1951:
1952: //sanity check on the directory
1953: sanityCheck(dir);
1954:
1955: //we only want to write out the VDS properties for time being
1956: Properties properties = mProps.matchingSubset("pegasus", true);
1957:
1958: //create a temporary file in directory
1959: File f = File.createTempFile("pegasus.", ".properties", dir);
1960:
1961: //the header of the file
1962: StringBuffer header = new StringBuffer(64);
1963: header.append("Pegasus USER PROPERTIES AT RUNTIME \n").append(
1964: "#ESCAPES IN VALUES ARE INTRODUCED");
1965:
1966: //create an output stream to this file and write out the properties
1967: OutputStream os = new FileOutputStream(f);
1968: properties.store(os, header.toString());
1969: os.close();
1970:
1971: //also set it to the internal variable
1972: mPropsInSubmitDir = f.getAbsolutePath();
1973: return mPropsInSubmitDir;
1974: }
1975:
1976: /**
1977: * Checks the destination location for existence, if it can
1978: * be created, if it is writable etc.
1979: *
1980: * @param dir is the new base directory to optionally create.
1981: *
1982: * @throws IOException in case of error while writing out files.
1983: */
1984: protected static void sanityCheck(File dir) throws IOException {
1985: if (dir.exists()) {
1986: // location exists
1987: if (dir.isDirectory()) {
1988: // ok, isa directory
1989: if (dir.canWrite()) {
1990: // can write, all is well
1991: return;
1992: } else {
1993: // all is there, but I cannot write to dir
1994: throw new IOException(
1995: "Cannot write to existing directory "
1996: + dir.getPath());
1997: }
1998: } else {
1999: // exists but not a directory
2000: throw new IOException("Destination " + dir.getPath()
2001: + " already "
2002: + "exists, but is not a directory.");
2003: }
2004: } else {
2005: // does not exist, try to make it
2006: if (!dir.mkdirs()) {
2007: throw new IOException(
2008: "Unable to create directory destination "
2009: + dir.getPath());
2010: }
2011: }
2012: }
2013:
2014: /**
2015: * Logs a warning about the deprecated property. Logs a warning only if
2016: * it has not been displayed before.
2017: *
2018: * @param deprecatedProperty the deprecated property that needs to be
2019: * replaced.
2020: * @param newProperty the new property that should be used.
2021: */
2022: private void logDeprecatedWarning(String deprecatedProperty,
2023: String newProperty) {
2024:
2025: if (!mDeprecatedProperties.contains(deprecatedProperty)) {
2026: //log only if it had already not been logged
2027: StringBuffer sb = new StringBuffer();
2028: sb.append("The property ").append(deprecatedProperty)
2029: .append(" has been deprecated. Use ").append(
2030: newProperty).append(" instead.");
2031: mLogger
2032: .log(sb.toString(),
2033: LogManager.WARNING_MESSAGE_LEVEL);
2034:
2035: //push the property in to indicate it has already been
2036: //warned about
2037: mDeprecatedProperties.add(deprecatedProperty);
2038: }
2039: }
2040:
2041: /**
2042: * Returns a boolean indicating whether to use third party transfers for
2043: * all types of transfers or not.
2044: *
2045: * Referred to by the "pegasus.transfer.*.thirdparty" property.
2046: *
2047: * @return the boolean value in the properties files,
2048: * else false if no value specified, or non boolean specified.
2049: */
2050: // private boolean useThirdPartyForAll(){
2051: // return Boolean.parse("pegasus.transfer.*.thirdparty",
2052: // false);
2053: // }
2054:
2055: /**
2056: * Returns the default list of third party sites.
2057: *
2058: * Referred to by the "pegasus.transfer.*.thirdparty.sites" property.
2059: *
2060: * @return the value specified in the properties file, else
2061: * null.
2062: */
2063: private String getDefaultThirdPartySites() {
2064: return mProps
2065: .getProperty("pegasus.transfer.*.thirdparty.sites");
2066: }
2067:
2068: /**
2069: * Returns the default transfer implementation to be picked up for
2070: * constructing transfer jobs.
2071: *
2072: * Referred to by the "pegasus.transfer.*.impl" property.
2073: *
2074: * @return the value specified in the properties file, else
2075: * null.
2076: */
2077: private String getDefaultTransferImplementation() {
2078: return mProps.getProperty("pegasus.transfer.*.impl");
2079: }
2080:
2081: /**
2082: * Returns the default priority for the transfer jobs if specified in
2083: * the properties file.
2084: *
2085: * @return the value specified in the properties file, else null if
2086: * non integer value or no value specified.
2087: */
2088: private String getDefaultTransferPriority() {
2089: String prop = mProps
2090: .getProperty(this .ALL_TRANSFER_PRIORITY_PROPERTY);
2091: int val = -1;
2092:
2093: try {
2094: val = Integer.parseInt(prop);
2095: } catch (Exception e) {
2096: return null;
2097: }
2098: return Integer.toString(val);
2099: }
2100:
2101: /**
2102: * Gets the reference to the internal singleton object. This method is
2103: * invoked with the assumption that the singleton method has been invoked once
2104: * and has been populated. Also that it has not been disposed by the garbage
2105: * collector. Can be potentially a buggy way to invoke.
2106: *
2107: * @return a handle to the Properties class.
2108: */
2109: // public static PegasusProperties singletonInstance() {
2110: // return singletonInstance( null );
2111: // }
2112: /**
2113: * Gets a reference to the internal singleton object.
2114: *
2115: * @param propFileName name of the properties file to picked
2116: * from $PEGASUS_HOME/etc/ directory.
2117: *
2118: * @return a handle to the Properties class.
2119: */
2120: // public static PegasusProperties singletonInstance( String propFileName ) {
2121: // if ( pegProperties == null ) {
2122: // //only the default properties file
2123: // //can be picked up due to the way
2124: // //Singleton implemented in VDSProperties.???
2125: // pegProperties = new PegasusProperties( null );
2126: // }
2127: // return pegProperties;
2128: // }
2129: }
|