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.generator;
015:
016: import org.griphyn.cPlanner.classes.ADag;
017: import org.griphyn.cPlanner.classes.SubInfo;
018: import org.griphyn.cPlanner.classes.PlannerOptions;
019:
020: import org.griphyn.cPlanner.code.CodeGenerator;
021: import org.griphyn.cPlanner.code.generator.condor.CondorGenerator;
022:
023: import org.griphyn.cPlanner.common.PegasusProperties;
024:
025: import java.io.BufferedWriter;
026: import java.io.File;
027: import java.io.FileWriter;
028: import java.io.PrintWriter;
029: import java.io.IOException;
030:
031: /**
032: * A Condor Submit Writer, that understands the notion of hashed file directories.
033: *
034: * @author Karan Vahi
035: * @version $Revision: 50 $
036: */
037: public class HashedFile extends CondorGenerator {
038:
039: /**
040: * The default constructor.
041: */
042: public HashedFile() {
043: super ();
044: }
045:
046: /**
047: * Returns an open stream to the file that is used for writing out the
048: * job information for the job.
049: *
050: * @param job the job whose job information needs to be written.
051: *
052: * @return the writer to the open file.
053: * @exception IOException if unable to open a write handle to the file.
054: */
055: public PrintWriter getWriter(SubInfo job) throws IOException {
056: // String jobDir = job.getSubmitDirectory();
057: StringBuffer sb = new StringBuffer();
058:
059: //determine the absolute submit directory for the job
060: // sb.append( GridStart.getSubmitDirectory( mSubmitFileDir, job ));
061: sb.append(mSubmitFileDir);
062:
063: //append the base name of the job
064: sb.append(File.separatorChar).append(getFileBaseName(job));
065:
066: // intialize the print stream to the file
067: return new PrintWriter(new BufferedWriter(new FileWriter(sb
068: .toString())));
069: }
070:
071: /**
072: * Returns the path relative to the workflow submit directory of the file to
073: * which the job is written to.
074: *
075: * @param job the job whose job information needs to be written.
076: *
077: * @return the relative path of the file.
078: */
079: /*
080: public String getDAGMANFilename(SubInfo job){
081: //do the correct but the inefficient way.
082: String name = "";
083:
084: //get the absolute directory first
085: String absolute = GridStart.getSubmitDirectory( mSubmitFileDir, job );
086: if (absolute.indexOf( mSubmitFileDir ) == 0){
087:
088: if(absolute.length() > mSubmitFileDir.length()){
089: name = absolute.substring(mSubmitFileDir.length());
090:
091: //remove the file separator if present at the starting
092: name = (name.indexOf( File.separatorChar) == 0)?
093: name.substring(1):
094: name;
095:
096: name += File.separatorChar;
097: }
098: else{
099: //empty. no relative directory
100: }
101: }
102: else{
103: //the absolute path does not contain the submit file directory
104: //root. Should not really be the case.
105: name = absolute;
106: name += File.separatorChar;
107: }
108:
109: name += this.getFileBaseName(job);
110:
111: return name;
112: }
113: */
114:
115: }
|