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: */package org.griphyn.cPlanner.code;
015:
016: import org.griphyn.cPlanner.classes.ADag;
017: import org.griphyn.cPlanner.classes.PegasusBag;
018: import org.griphyn.cPlanner.classes.SubInfo;
019: import org.griphyn.cPlanner.classes.AggregatedJob;
020:
021: import java.util.Collection;
022:
023: import java.io.File;
024:
025: /**
026: * The interface that defines how a job specified in the abstract workflow
027: * is launched on the grid. This allows to specify different ways to wrap
028: * an executable while running on the grid. One may do this, to gather
029: * additional information about the job like provenance information.
030: *
031: * If the implementation returns true for canSetXBit, then it should be setting
032: * the X bit for the staged compute jobs.
033: *
034: * @author Karan Vahi vahi@isi.edu
035: * @version $Revision: 410 $
036: */
037: public interface GridStart {
038:
039: /**
040: * The version number associated with this API of GridStart.
041: */
042: public static final String VERSION = "1.5";
043:
044: /**
045: * The File separator to be used on the submit host.
046: */
047: public static char mSeparator = File.separatorChar;
048:
049: /**
050: * Initializes the GridStart implementation.
051: *
052: * @param bag the bag of objects that is used for initialization.
053: * @param dag the concrete dag so far.
054: */
055: public void initialize(PegasusBag bag, ADag dag);
056:
057: /**
058: * Enables a collection of jobs and puts them into an AggregatedJob.
059: * The assumption here is that all the jobs are being enabled by the same
060: * implementation. It is upto the implementation to determine whether it
061: * wants to return a new AggregatedJob by cloning the one passed or just
062: * modify the one passed to it.
063: *
064: * @param aggJob the AggregatedJob into which the collection has to be
065: * integrated.
066: * @param jobs the collection of jobs (SubInfo) that need to be enabled.
067: *
068: * @return the AggregatedJob containing the enabled jobs.
069: * @see #enable(SubInfo,boolean)
070: */
071: public AggregatedJob enable(AggregatedJob aggJob, Collection jobs);
072:
073: /**
074: * Enables a job to run on the grid. This also determines how the
075: * stdin,stderr and stdout of the job are to be propogated.
076: * To grid enable a job, the job may need to be wrapped into another
077: * job, that actually launches the job. It usually results in the job
078: * description passed being modified modified.
079: *
080: * @param job the <code>SubInfo</code> object containing the job description
081: * of the job that has to be enabled on the grid.
082: * @param isGlobusJob is <code>true</code>, if the job generated a
083: * line <code>universe = globus</code>, and thus runs remotely.
084: * Set to <code>false</code>, if the job runs on the submit
085: * host in any way.
086: *
087: * @return boolean true if enabling was successful,else false.
088: */
089: public boolean enable(SubInfo job, boolean isGlobusJob);
090:
091: /**
092: * Constructs the postscript that has to be invoked on the submit host
093: * after the job has executed on the remote end. The postscript usually
094: * works on the output generated by the executable that is used to grid
095: * enable a job, and has been piped back by Condor.
096: * <p>
097: * The postscript should be constructed and populated as a profile
098: * in the DAGMAN namespace.
099: *
100: *
101: * @param job the <code>SubInfo</code> object containing the job description
102: * of the job that has to be enabled on the grid.
103: * @param key the key for the profile that has to be inserted.
104: *
105: * @return boolean true if postscript was generated,else false.
106: */
107: // public boolean constructPostScript( SubInfo job, String key ) ;
108: /**
109: * Indicates whether the enabling mechanism can set the X bit
110: * on the executable on the remote grid site, in addition to launching
111: * it on the remote grid stie
112: *
113: * @return boolean indicating whether can set the X bit or not.
114: */
115: public boolean canSetXBit();
116:
117: /**
118: * Returns the value of the vds profile with key as VDS.GRIDSTART_KEY,
119: * that would result in the loading of this particular implementation.
120: * It is usually the name of the implementing class without the
121: * package name.
122: *
123: * @return the value of the profile key.
124: * @see org.griphyn.cPlanner.namespace.VDS#GRIDSTART_KEY
125: */
126: public String getVDSKeyValue();
127:
128: /**
129: * Returns a short textual description of the implementing class.
130: * Should usually be the name of the implementing class.
131: *
132: * @return short textual description.
133: */
134: public String shortDescribe();
135:
136: /**
137: * Returns the SHORT_NAME for the POSTScript implementation that is used
138: * to be as default with this GridStart implementation.
139: *
140: * @return the id for the POSTScript.
141: *
142: * @see POSTScript#shortDescribe()
143: */
144: public String defaultPOSTScript();
145:
146: /**
147: * Returns the full path to the submit directory, for the job.
148: *
149: * @param root the base of the submit directory hierarchy for the workflow.
150: * @param job the job for which the submit directory is to be determined.
151: *
152: * @return the path to the submit directory.
153: */
154: // public static String getSubmitDirectory( String root, SubInfo job ){
155: // String jobDir = job.getSubmitDirectory();
156: // StringBuffer sb = new StringBuffer();
157: //
158: // //some sanity checks
159: // if( jobDir == null && root == null){
160: // throw new NullPointerException(
161: // "Both the root directory, and job directory are null");
162: // }
163: //
164: //
165: // //determine the submit directory for the job
166: // if(jobDir == null){
167: // sb.append(root);
168: // }
169: // else if(jobDir.indexOf(mSeparator) == 0){
170: // //absolute path use that
171: // sb.append(jobDir);
172: // }
173: // else{
174: // //handle the . if given
175: // sb.append(root).append(mSeparator);
176: // sb.append((jobDir.indexOf('.') == 0)?
177: // //handle separator if given
178: // (jobDir.indexOf(mSeparator) == 1)?
179: // jobDir.substring(2):jobDir.substring(1)
180: // //just append whatever is given
181: // :jobDir);
182: // }
183: //
184: // return sb.toString();
185: // }
186:
187: }
|