00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.process.globus;
00032
00033 import org.objectweb.proactive.core.process.AbstractExternalProcessDecorator;
00034 import org.objectweb.proactive.core.process.JVMProcess;
00035 import org.objectweb.proactive.core.process.JVMProcessImpl;
00036 import org.objectweb.proactive.core.process.UniversalProcess;
00037
00038
00046 public class GlobusProcess extends AbstractExternalProcessDecorator {
00047 protected JVMProcessImpl jvmProcess;
00048 protected String count = "1";
00049 protected String stderr = null;
00050 protected String stdout = null;
00051 protected String queue = null;
00052 protected String maxTime = null;
00053
00054
00055
00056
00057
00061 public GlobusProcess() {
00062 super();
00063 setCompositionType(GIVE_COMMAND_AS_PARAMETER);
00064 this.hostname = null;
00065 }
00066
00070 public GlobusProcess(JVMProcess process) {
00071 super(process, GIVE_COMMAND_AS_PARAMETER);
00072 this.jvmProcess = (JVMProcessImpl) targetProcess;
00073 this.hostname = null;
00074 }
00075
00076
00077
00078
00079 protected String internalBuildCommand() {
00080 return buildRSLCommand();
00081 }
00082
00083 public static void main(String[] args) {
00084 String RSL = "& (executable = /nfs/software/java/j2sdk1.4.2_07/bin/java )(count=5)";
00085
00086
00087 GridJob Job1 = new GridJob("viz-login.isi.edu/jobmanager-pbs", false);
00088
00089
00090 Job1.GlobusRun(RSL);
00091
00092
00093 }
00094
00095 protected void internalStartProcess(String rslCommand)
00096 throws java.io.IOException {
00097 GridJob Job1 = new GridJob(hostname, false);
00098 String jobOut = Job1.GlobusRun(getCommand());
00099 logger.info(jobOut);
00100 }
00101
00106 private String buildRSLCommand() {
00107
00108
00109 String java_command = ((JVMProcess) getTargetProcess()).getJavaPath();
00110 String initial_args = ((JVMProcess) getTargetProcess()).getCommand()
00111 .substring(java_command.length() + 1);
00112
00113
00114
00115
00116 String args = checkSyntax(initial_args);
00117
00118 String RSLCommand = "& (executable = " + java_command + ")(arguments=" +
00119 args + ")(count=" + count + ")";
00120
00121 if (stdout != null) {
00122 RSLCommand = RSLCommand + "(stdout=" + stdout + ")";
00123 }
00124
00125 if (stderr != null) {
00126 RSLCommand = RSLCommand + "(stderr=" + stderr + ")";
00127 }
00128
00129 if (queue != null) {
00130 RSLCommand = RSLCommand + "(queue=" + queue + ")";
00131 }
00132
00133 if (environment != null) {
00134 RSLCommand = RSLCommand + "(environment=" +
00135 buildEnvironmentCommand() + ")";
00136 }
00137 if (maxTime != null) {
00138 RSLCommand = RSLCommand + "(maxTime=" + maxTime + ")";
00139 }
00140 return RSLCommand;
00141 }
00142
00143 protected String buildEnvironmentCommand() {
00144 if (environment == null) {
00145 return "";
00146 }
00147 StringBuilder sb = new StringBuilder();
00148 String[] globusEnvironment = new String[environment.length];
00149 for (int i = 0; i < environment.length; i++) {
00150 globusEnvironment[i] = environment[i].replace('=', ' ');
00151 sb.append("(");
00152 sb.append(globusEnvironment[i]);
00153 sb.append(")");
00154 }
00155 return sb.toString();
00156 }
00157
00162 public String getCount() {
00163 return count;
00164 }
00165
00170 public void setCount(String count) {
00171 this.count = count;
00172 }
00173
00177 public String getProcessId() {
00178 return "globus_" + targetProcess.getProcessId();
00179 }
00180
00184 public int getNodeNumber() {
00185 return (new Integer(getCount()).intValue());
00186 }
00187
00191 public UniversalProcess getFinalProcess() {
00192 checkStarted();
00193 return targetProcess.getFinalProcess();
00194 }
00195
00199 private String checkSyntax(String args) {
00200 String formatted_args = "";
00201 String[] splitted_args = args.split("\\s");
00202 for (int i = 0; i < splitted_args.length; i++) {
00203 if (!(splitted_args[i].indexOf("=") < 0)) {
00204 splitted_args[i] = "\"" + splitted_args[i] + "\"";
00205 }
00206 formatted_args = formatted_args + " " + splitted_args[i];
00207 }
00208 return formatted_args;
00209 }
00210
00214 public String getStderr() {
00215 return stderr;
00216 }
00217
00221 public void setStderr(String stderr) {
00222 this.stderr = stderr;
00223 }
00224
00228 public String getStdout() {
00229 return stdout;
00230 }
00231
00235 public void setStdout(String stdout) {
00236 this.stdout = stdout;
00237 }
00238
00242 public String getQueue() {
00243 return queue;
00244 }
00245
00249 public void setQueue(String queue) {
00250 this.queue = queue;
00251 }
00252
00253 public String getMaxTime() {
00254 return maxTime;
00255 }
00256
00257 public void setMaxTime(String maxTime) {
00258 this.maxTime = maxTime;
00259 }
00260 }