001: /*
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found in file GTPL, or at
004: * http://www.globus.org/toolkit/download/license.html. This notice must
005: * appear in redistributions of this file, with or without modification.
006: *
007: * Redistributions of this Software, with or without modification, must
008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009: * some other similar material which is provided with the Software (if
010: * any).
011: *
012: * Copyright 1999-2004 University of Chicago and The University of
013: * Southern California. All rights reserved.
014: */
015: package org.griphyn.cPlanner.transfer;
016:
017: import org.griphyn.cPlanner.transfer.Refiner;
018:
019: import org.griphyn.cPlanner.classes.ADag;
020: import org.griphyn.cPlanner.classes.SubInfo;
021: import org.griphyn.cPlanner.classes.PlannerOptions;
022:
023: import org.griphyn.cPlanner.common.PegasusProperties;
024: import org.griphyn.cPlanner.common.LogManager;
025: import org.griphyn.cPlanner.common.TPT;
026:
027: import org.griphyn.cPlanner.provenance.pasoa.XMLProducer;
028: import org.griphyn.cPlanner.provenance.pasoa.producer.XMLProducerFactory;
029:
030: /**
031: * An abstract implementation that implements some of the common functions
032: * in the Refiner Interface and member variables that are required by all the
033: * refiners.
034: *
035: * @author Karan Vahi
036: * @version $Revision: 244 $
037: */
038:
039: public abstract class AbstractRefiner implements Refiner {
040:
041: /**
042: * The stage-in transfer implementation that the refiner requires.
043: */
044: protected Implementation mTXStageInImplementation;
045:
046: /**
047: * The inter transfer implementation that the refiner requires.
048: */
049: protected Implementation mTXInterImplementation;
050:
051: /**
052: * The stage-out transfer implementation that the refiner requires.
053: */
054: protected Implementation mTXStageOutImplementation;
055:
056: /**
057: * The ADag object associated with the Dag. This is the object to
058: * which the transfer nodes are added. This object is initialised in the
059: * TransferEngine.
060: */
061: protected ADag mDAG;
062:
063: /**
064: * The handle to the properties object holding the properties relevant to
065: * Pegasus.
066: */
067: protected PegasusProperties mProps;
068:
069: /**
070: * The options passed to the planner at runtime.
071: */
072: protected PlannerOptions mPOptions;
073:
074: /**
075: * The logging object which is used to log all the messages.
076: *
077: * @see org.griphyn.cPlanner.common.LogManager
078: */
079: protected LogManager mLogger;
080:
081: /**
082: * The handle to the Third Party State machinery.
083: */
084: protected TPT mTPT;
085:
086: /**
087: * The XML Producer object that records the actions.
088: */
089: protected XMLProducer mXMLStore;
090:
091: /**
092: * The overloaded constructor.
093: *
094: * @param dag the workflow to which transfer nodes need to be added.
095: * @param properties the <code>PegasusProperties</code> object containing all
096: * the properties required by Pegasus.
097: * @param options the options passed to the planner.
098: */
099: public AbstractRefiner(ADag dag, PegasusProperties properties,
100: PlannerOptions options) {
101: mLogger = LogManager.getInstance();
102: mDAG = dag;
103: mProps = properties;
104: mPOptions = options;
105: mTPT = new TPT(properties);
106: mTPT.buildState();
107: mXMLStore = XMLProducerFactory.loadXMLProducer(properties);
108: }
109:
110: /**
111: * Returns a reference to the workflow that is being refined by the refiner.
112: *
113: *
114: * @return ADAG object.
115: */
116: public ADag getWorkflow() {
117: return this .mDAG;
118: }
119:
120: /**
121: * Returns a reference to the XMLProducer, that generates the XML fragment
122: * capturing the actions of the refiner. This is used for provenace
123: * purposes.
124: *
125: * @return XMLProducer
126: */
127: public XMLProducer getXMLProducer() {
128: return this .mXMLStore;
129: }
130:
131: /**
132: * Returns whether a Site is third party enabled or not.
133: *
134: * @param site the name of the site.
135: * @param type the type of transfer job for which the URL is being constructed.
136: * Should be one of the following:
137: * stage-in
138: * stage-out
139: * inter-pool transfer
140: *
141: * @return true pool is third party enabled
142: * false pool is not third party enabled.
143: *
144: * @see SubInfo#STAGE_IN_JOB
145: * @see SubInfo#INTER_POOL_JOB
146: * @see SubInfo#STAGE_OUT_JOB
147: *
148: * @throws IllegalArgumentException
149: */
150: public boolean isSiteThirdParty(String site, int type) {
151: Implementation implementation;
152: //the value from the properties file
153: //later on maybe picked up as profiles
154: boolean useTPT = false;
155: if (type == SubInfo.STAGE_IN_JOB) {
156: implementation = mTXStageInImplementation;
157: useTPT = mTPT.stageInThirdParty(site);
158: } else if (type == SubInfo.INTER_POOL_JOB) {
159: implementation = mTXInterImplementation;
160: useTPT = mTPT.interThirdParty(site);
161: } else if (type == SubInfo.STAGE_OUT_JOB) {
162: implementation = mTXStageOutImplementation;
163: useTPT = mTPT.stageOutThirdParty(site);
164: } else {
165: throw new java.lang.IllegalArgumentException(
166: "Invalid implementation type passed " + type);
167: }
168:
169: return implementation.useThirdPartyTransferAlways() || useTPT;
170: }
171:
172: /**
173: * Returns whether the third party transfers for a particular site are to
174: * be run on the remote site or the submit host.
175: *
176: * @param site the name of the site.
177: * @param type the type of transfer job for which the URL is being constructed.
178: * Should be one of the following:
179: * stage-in
180: * stage-out
181: * inter-pool transfer
182: *
183: * @return true if the transfers are to be run on remote site, else false.
184: *
185: * @see SubInfo#STAGE_IN_JOB
186: * @see SubInfo#INTER_POOL_JOB
187: * @see SubInfo#STAGE_OUT_JOB
188: */
189: public boolean runTPTOnRemoteSite(String site, int type) {
190: Implementation implementation;
191: //the value from the properties file
192: //later on maybe picked up as profiles
193: boolean remoteTPT = false;
194: if (type == SubInfo.STAGE_IN_JOB) {
195: implementation = mTXStageInImplementation;
196: remoteTPT = mTPT.stageInThirdPartyRemote(site);
197: } else if (type == SubInfo.INTER_POOL_JOB) {
198: implementation = mTXInterImplementation;
199: remoteTPT = mTPT.interThirdPartyRemote(site);
200: } else if (type == SubInfo.STAGE_OUT_JOB) {
201: implementation = mTXStageOutImplementation;
202: remoteTPT = mTPT.stageOutThirdPartyRemote(site);
203: } else {
204: throw new java.lang.IllegalArgumentException(
205: "Invalid implementation type passed " + type);
206: }
207:
208: return remoteTPT;
209:
210: }
211:
212: /**
213: * Logs configuration messages regarding the type of implementations loaded
214: * for various type of transfer node creations.
215: */
216: protected void logConfigMessages() {
217: //log a message
218: mLogger.log("Transfer Implementation loaded for Stage-In ["
219: + mTXStageInImplementation.getDescription() + "]",
220: LogManager.CONFIG_MESSAGE_LEVEL);
221: mLogger.log("Transfer Implementation loaded for Inter Site ["
222: + mTXInterImplementation.getDescription() + "]",
223: LogManager.CONFIG_MESSAGE_LEVEL);
224: mLogger.log("Transfer Implementation loaded for Stage-Out ["
225: + mTXStageOutImplementation.getDescription() + "]",
226: LogManager.CONFIG_MESSAGE_LEVEL);
227:
228: }
229:
230: }
|