001 /* 002 * OutputCopyAction.java 003 * 004 * Created on February 11, 2004, 12:17 PM 005 * 006 * This file is part of the STAR Scheduler. 007 * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory 008 * 009 * STAR Scheduler is free software; you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as published by 011 * the Free Software Foundation; either version 2 of the License, or 012 * (at your option) any later version. 013 * 014 * STAR Scheduler is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public License 020 * along with STAR Scheduler; if not, write to the Free Software 021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 022 */ 023 024 package gov.bnl.star.offline.scheduler; 025 026 import java.net.URI; 027 import java.util.List; 028 029 /** 030 * An OutputAction for copying output date to a differnt location. 031 * @author Carcassi & Hajdu 032 */ 033 public class OutputCopyAction extends OutputAction implements java.io.Serializable { 034 035 private String fileRef; 036 private String storageService; 037 private URI uri; 038 039 /** Creates a new instance of OutputCopyAction */ 040 public OutputCopyAction(List actionList, String id, String referto, String to, int retries, int sleep, String type){ 041 042 this.SetActionList(actionList); 043 this.setID(id); 044 this.setReferTo(referto); 045 this.setTo(to); 046 this.setRetries(retries); 047 this.setSleep(sleep); 048 this.type = type; 049 } 050 051 public OutputCopyAction(){}; 052 053 String type; 054 public void setType(String type) {this.type = type;} 055 public String getType(){return type;} 056 057 /** Returns the name of the action, which is always copy for a CopyAction. 058 */ 059 // public String getName() { return "copy"; } 060 061 /** Returns the reference name for the target file. The target file is 062 * the destination of the copy. 063 */ 064 //public String getFileRef() { //return fileRef; 065 // return "Reg1";} 066 067 //public void setFileRef(String fileRef){this.fileRef = fileRef;} 068 069 /** Returns the URI of the copy action describing the destination of the copy. 070 * The URI should be either a full URI if storageService is not present, 071 * or it should be a relative path. The URI will not be a full path in that 072 * case, since the fullpath will be determined inside the job, once the 073 * main command is finished. 074 */ 075 //public URI getURI() { return uri; } 076 //public void setURI(URI uri){this.uri = uri;} 077 078 /** Returns the storageService query, which will be used by the job to 079 * determine the first part of the URI for the final destination of the 080 * copy. 081 */ 082 // public String getStorageService() { return storageService; } 083 //public void SetStorageService(String storageService) { this.storageService = storageService; } 084 085 /** Returns true, as all CopyActions are reference generators. Being a reference 086 * generator means that in the script they are able to determine the location 087 * of the target files. Copy actions will determine the target location either 088 * with the URI, or by combining the URI with the result of the storageService 089 * query. In any case, the copy action will prepare an environment variable 090 * with the full target URI, which can then be used by other actions that 091 * use the same reference 092 */ 093 //public boolean isReferenceGenerator() { return true; } 094 095 public String getScriptName() { return "SUMScopy.csh"; } 096 097 098 /** */ 099 public String makeScriptString(String outputFile, String gateway) { 100 101 setOutputFile(outputFile); 102 103 if(this.getReferTo() != null){ //resolve the referTo 104 outputFile = this.findReferTo(this.GetActionList(), getReferTo() ); 105 } 106 107 //after this is working this path will be moved out to program localtions in the config file 108 String command = getScriptName() + " "; 109 if( getType()!= null ) command = command.concat("\"" + getType() + "\" "); 110 command = command.concat("\""+ gateway +"\" \""+ outputFile +"\" \""+ getTo() +"\" " ); 111 112 113 if(getRetries() > 0){ 114 command = command.concat(String.valueOf(getRetries()) +" "); 115 if(getSleep() > 0) command = command.concat(String.valueOf(getSleep())); 116 } 117 118 return command + "\n"; 119 } 120 121 }