1 31 32 37 package org.objectweb.proactive.core.process.globus; 38 39 import org.objectweb.proactive.core.process.AbstractExternalProcessDecorator; 40 import org.objectweb.proactive.core.process.JVMProcess; 41 import org.objectweb.proactive.core.process.JVMProcessImpl; 42 43 44 50 public class GlobusProcess extends AbstractExternalProcessDecorator { 51 protected JVMProcessImpl jvmProcess; 52 private static final String FILE_SEPARATOR = System.getProperty( 53 "file.separator"); 54 private static final String DEFAULT_SCRIPT_LOCATION = System.getProperty( 55 "user.home") + FILE_SEPARATOR + "ProActive" + FILE_SEPARATOR + 56 "scripts" + FILE_SEPARATOR + "unix" + FILE_SEPARATOR + "cluster" + 57 FILE_SEPARATOR + "startRuntime.sh "; 58 private String count = "1"; 59 private String scriptLocation = DEFAULT_SCRIPT_LOCATION; 60 61 65 68 public GlobusProcess() { 69 super(); 70 setCompositionType(GIVE_COMMAND_AS_PARAMETER); 71 this.hostname = null; 72 } 73 74 77 public GlobusProcess(JVMProcess process) { 78 super(process, GIVE_COMMAND_AS_PARAMETER); 79 this.jvmProcess = (JVMProcessImpl) targetProcess; 80 this.hostname = null; 81 } 82 83 86 protected String internalBuildCommand() { 87 return buildRSLCommand(); 88 } 89 90 public static void main(String [] args) { 91 String RSL = "& (executable = " + DEFAULT_SCRIPT_LOCATION + 93 ")(count=5)"; 94 GridJob Job1 = new GridJob("cluster.inria.fr", false); 95 96 String jobOut = Job1.GlobusRun(RSL); 97 98 System.out.println(jobOut); 99 } 100 101 protected void internalStartProcess(String rslCommand) 102 throws java.io.IOException { 103 GridJob Job1 = new GridJob(hostname, true); 104 String jobOut = Job1.GlobusRun(getCommand()); 105 106 logger.info(jobOut); 108 } 109 110 114 private String buildRSLCommand() { 115 String RSLCommand = "& (executable = " + scriptLocation + 116 ")(arguments='" + getTargetProcess().getCommand() + "')(count=" + 117 count + ")(jobType=single)"; 118 119 if (environment != null) { 122 RSLCommand = RSLCommand + "(environment=" + 123 buildEnvironmentCommand() + ")"; 124 } 125 return RSLCommand; 126 } 133 134 protected String buildEnvironmentCommand() { 135 if (environment == null) { 136 return ""; 137 } 138 StringBuffer sb = new StringBuffer (); 139 String [] globusEnvironment = new String [environment.length]; 140 for (int i = 0; i < environment.length; i++) { 141 globusEnvironment[i] = environment[i].replace('=', ' '); 142 sb.append("("); 143 sb.append(globusEnvironment[i]); 144 sb.append(")"); 145 } 146 return sb.toString(); 147 } 148 149 153 public String getCount() { 154 return count; 155 } 156 157 161 public void setCount(String count) { 162 this.count = count; 163 } 164 165 169 public String getScriptLocation() { 170 return scriptLocation; 171 } 172 173 177 public void setScriptLocation(String scriptLocation) { 178 this.scriptLocation = scriptLocation; 179 } 180 } 181 | Popular Tags |