001 /* 002 * OutputAction.java 003 * 004 * Created on February 11, 2004, 2:27 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 import java.util.List; 026 import java.net.URI; 027 028 /**Description of what to do with the output. 029 * @author Carcassi & Hajdu 030 */ 031 public abstract class OutputAction { 032 033 /** Returns the name of the action. For example, copy for a copy action and 034 * register action. Typically, the name would be the same as the element 035 * name in the XML description. 036 */ 037 // public abstract String getName(); 038 039 /** Returns true if this action is able to generate reference for itself and 040 * for other actions. The first action on every reference must be a reference 041 * generator. All subsequent must be non reference generator. Translated in the 042 * script, being a reference generator means preparing an environment variable 043 * that can be used as a reference for a particular copy of the file. Some 044 * actions will be creating the reference, some other will just be using it 045 * to carry out their action. 046 */ 047 // public abstract boolean isReferenceGenerator(); 048 049 /** Returns the reference to the target copy of the action. A file can have 050 * multiple copies due to the output actions, and the reference would 051 * distinguish between them. 052 */ 053 // public abstract String getFileRef(); 054 055 056 private String ID = null; 057 public String getID() {return ID;} 058 public void setID(String ID) {this.ID = ID;} 059 060 private String referTo = null; 061 public void setReferTo(String referTo) { this.referTo = referTo; } 062 public String getReferTo() {return referTo; } 063 064 private String to = null; 065 public void setTo(String to) { this.to = to; } 066 public String getTo() {return to; } 067 068 private int retries = 0; 069 public int getRetries() { return retries;} 070 public void setRetries(int retries) {this.retries = retries;} 071 072 private int sleep = -1; //sleep time 073 public int getSleep() { return sleep; } 074 public void setSleep(int sleep) {this.sleep = sleep;} 075 076 private List actionList; 077 public void SetActionList(List actionList){this.actionList = actionList;} 078 public List GetActionList(){return actionList;} 079 080 private String outputFile; 081 public void setOutputFile(String outputFile){this.outputFile = outputFile;} 082 public String getOutputFile(){return outputFile;} 083 084 public abstract String getScriptName(); 085 public abstract String makeScriptString(String outputFile, String gateway); 086 087 088 /** Returns the name of the file that is */ 089 public String getExpectedActionResultFile(){ 090 return "somefile"; 091 } 092 093 public String findReferTo(List actionlList, String referTo){ 094 for (int nOutputAction = 0; nOutputAction < actionlList.size(); nOutputAction++) { 095 OutputAction outputAction = (OutputAction) actionlList.get(nOutputAction); 096 if(outputAction.ID != null){ 097 if(outputAction.ID.compareTo(referTo) == 0) { 098 099 if(! outputAction.getTo().endsWith("/")) return outputAction.getTo(); //if the to already has to file name at the back of it just return the value 100 else if(outputAction.getOutputFile().indexOf("/") == -1) return outputAction.getTo() + outputAction.getOutputFile(); 101 else return outputAction.getTo() + outputAction.getOutputFile().substring(outputAction.getOutputFile().lastIndexOf("/") + 1); //If the output file name has a path befor 102 103 } 104 } 105 } 106 107 throw new RuntimeException("Could to reslove referTo=\"" + referTo + "\"\n"); 108 } 109 110 111 /* 112 public String resolveRerferTo(List outputActionList, String referTo){ 113 for(int i = 0; outputActionList.size() != i; i++){ 114 OutputAction action = (OutputAction) outputActionList.get(i); 115 if(action.getID().compareTo(referTo)==0) { 116 //return action.getEstimatedOutputFile(); 117 } 118 } 119 throw new RuntimeException("Could to reslove referTo=\"" + referTo + "\"\n"); 120 }*/ 121 122 123 }