|
From: <ha...@us...> - 2007-05-02 21:19:54
|
Revision: 1635
http://svn.sourceforge.net/cogkit/?rev=1635&view=rev
Author: hategan
Date: 2007-05-02 14:19:49 -0700 (Wed, 02 May 2007)
Log Message:
-----------
added jobtypes to the pbs provider
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties
trunk/current/src/cog/modules/provider-localscheduler/project.properties
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties 2007-04-11 21:12:03 UTC (rev 1634)
+++ trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties 2007-05-02 21:19:49 UTC (rev 1635)
@@ -14,3 +14,13 @@
# The path to qstat. The default assumes that qstat is in PATH
#
qstat=qstat
+
+
+#
+# If the jobType attribute is specified, then the PBS provider
+# will look for a property named "wrapper.<jobType>" and prepend
+# that to the executable line in the PBS script. It will also
+# substitute value of attributes in the job specification, using
+# the "$attrName" notation.
+#
+wrapper.mpi=mpirun -np $count
Modified: trunk/current/src/cog/modules/provider-localscheduler/project.properties
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/project.properties 2007-04-11 21:12:03 UTC (rev 1634)
+++ trunk/current/src/cog/modules/provider-localscheduler/project.properties 2007-05-02 21:19:49 UTC (rev 1635)
@@ -1,6 +1,6 @@
module.name = provider-localscheduler
long.name = Local providers for PBS/Torque and Cobalt
-version = 1.0
+version = 0.2
project = Java CoG Kit
lib.deps = -
debug = true
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2007-04-11 21:12:03 UTC (rev 1634)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2007-05-02 21:19:49 UTC (rev 1635)
@@ -78,7 +78,7 @@
String[] cmdline = new String[] { Properties.getProperties().getQSub(),
script.getAbsolutePath() };
if (logger.isDebugEnabled()) {
- logger.debug(cmdline[0]+" "+cmdline[1]);
+ logger.debug(cmdline[0] + " " + cmdline[1]);
}
Process process = Runtime.getRuntime().exec(cmdline, null, null);
@@ -154,6 +154,25 @@
wr.write(quote(spec.getEnvironmentVariable(name)));
wr.write('\n');
}
+ String type = (String) spec.getAttribute("jobType");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Job type: " + type);
+ }
+ if (type != null) {
+ String wrapper = Properties.getProperties().getProperty(
+ "wrapper." + type);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Wrapper: " + wrapper);
+ }
+ if (wrapper != null) {
+ wrapper = replaceVars(wrapper);
+ wr.write(wrapper);
+ wr.write(' ');
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Wrapper after variable substitution: " + wrapper);
+ }
+ }
wr.write(quote(spec.getExecutable()));
List args = spec.getArgumentsAsList();
if (args != null && args.size() > 0) {
@@ -188,7 +207,6 @@
char c = s.charAt(i);
if (c == '"' || c == '\\') {
sb.append('\\');
- break;
}
sb.append(c);
}
@@ -214,6 +232,50 @@
return out;
}
+ protected String replaceVars(String str) {
+ StringBuffer sb = new StringBuffer();
+ boolean escaped = false;
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ if (c == '\\') {
+ if (escaped) {
+ sb.append('\\');
+ }
+ else {
+ escaped = true;
+ }
+ }
+ else {
+ if (c == '$' && !escaped) {
+ if (i == str.length() - 1) {
+ sb.append('$');
+ }
+ else {
+ int e = str.indexOf(' ', i);
+ if (e == -1) {
+ e = str.length();
+ }
+ String name = str.substring(i + 1, e);
+ Object attr = spec.getAttribute(name);
+ if (attr != null) {
+ sb.append(attr.toString());
+ }
+ else {
+ sb.append('$');
+ sb.append(name);
+ }
+ i = e;
+ }
+ }
+ else {
+ sb.append(c);
+ }
+ escaped = false;
+ }
+ }
+ return sb.toString();
+ }
+
protected void cleanup() {
script.delete();
new File(exitcode).delete();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-08-20 22:33:16
|
Revision: 1694
http://cogkit.svn.sourceforge.net/cogkit/?rev=1694&view=rev
Author: hategan
Date: 2007-08-20 15:33:08 -0700 (Mon, 20 Aug 2007)
Log Message:
-----------
redirection stuff
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/execution/JobSubmissionTaskHandler.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/Job.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-20 22:33:08 UTC (rev 1694)
@@ -1,3 +1,7 @@
+(08/20/07)
+
+*** Redirection updates
+
(02/27/07)
*** I think Process.waitFor() can deadlock if there's too
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -109,8 +109,9 @@
}
getProcessPoller().addJob(
- new CobaltJob(jobid, spec.isRedirected(), stdout, stderr, spec
- .getStdOutput(), spec.getStdError(), this));
+ new CobaltJob(jobid, stdout, stderr, spec.getStdOutput(), spec
+ .getStdOutputLocation(), spec.getStdError(), spec
+ .getStdErrorLocation(), this));
}
private void error(String message) {
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -15,28 +15,33 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
import org.apache.log4j.Logger;
+import org.globus.cog.abstraction.impl.common.util.NullWriter;
+import org.globus.cog.abstraction.impl.common.util.WriterMultiplexer;
import org.globus.cog.abstraction.impl.scheduler.common.Job;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessException;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessListener;
+import org.globus.cog.abstraction.interfaces.FileLocation;
public class CobaltJob extends Job {
public static final Logger logger = Logger.getLogger(CobaltJob.class);
private String stdout, stderr, tstdout, tstderr;
- private boolean redirect;
+ private FileLocation outLoc, errLoc;
private int exitcode;
- public CobaltJob(String jobID, boolean redirect, String stdout,
- String stderr, String tstdout, String tstderr,
+ public CobaltJob(String jobID, String stdout,
+ String stderr, String tstdout, FileLocation outLoc, String tstderr, FileLocation errLoc,
ProcessListener listener) {
- super(jobID, null, null, null, listener);
- this.redirect = redirect;
+ super(jobID, null, null, null, null, null, listener);
this.stdout = stdout;
this.stderr = stderr;
this.tstdout = tstdout;
+ this.outLoc = outLoc;
this.tstderr = tstderr;
+ this.errLoc = errLoc;
int exitcode = Integer.MIN_VALUE;
}
@@ -54,37 +59,32 @@
protected boolean processStdout() {
try {
+ Writer wr = null;
CharArrayWriter caw = null;
- if (redirect) {
+ if (FileLocation.MEMORY.overlaps(outLoc)) {
caw = new CharArrayWriter();
+ wr = caw;
}
- BufferedWriter bw = null;
- if (tstdout != null) {
- bw = new BufferedWriter(new FileWriter(tstdout));
+ if (tstdout != null && LOCAL_AND_REMOTE.overlaps(outLoc)) {
+ wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(new FileWriter(tstdout)));
}
+ if (wr == null) {
+ wr = new NullWriter();
+ }
BufferedReader br = new BufferedReader(new FileReader(stdout));
String line;
do {
line = br.readLine();
if (line != null) {
- if (redirect) {
- caw.write(line);
- caw.write('\n');
- }
- else if (tstdout != null) {
- bw.write(line);
- bw.write('\n');
- }
+ wr.write(line);
+ wr.write('\n');
}
} while (line != null);
br.close();
+ wr.close();
if (caw != null) {
- caw.close();
listener.stdoutUpdated(caw.toString());
}
- if (bw != null) {
- bw.close();
- }
return true;
}
catch (Exception e) {
@@ -96,17 +96,23 @@
return false;
}
}
+
+ private static final FileLocation LOCAL_AND_REMOTE = FileLocation.LOCAL.and(FileLocation.REMOTE);
protected boolean processStderr() {
try {
+ Writer wr = null;
CharArrayWriter caw = null;
- if (redirect) {
+ if (FileLocation.MEMORY.overlaps(errLoc)) {
caw = new CharArrayWriter();
+ wr = caw;
}
- BufferedWriter bw = null;
- if (tstdout != null) {
- bw = new BufferedWriter(new FileWriter(tstderr));
+ if (tstdout != null && LOCAL_AND_REMOTE.overlaps(errLoc)) {
+ wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(new FileWriter(tstderr)));
}
+ if (wr == null) {
+ wr = new NullWriter();
+ }
BufferedReader br = new BufferedReader(new FileReader(stderr));
String line;
boolean started = false;
@@ -121,14 +127,8 @@
if (started) {
if (!line.startsWith("<")
|| line.indexOf("(Info)") == -1) {
- if (redirect) {
- caw.write(line);
- caw.write('\n');
- }
- else if (tstdout != null) {
- bw.write(line);
- bw.write('\n');
- }
+ wr.write(line);
+ wr.write('\n');
}
else {
int index = line.indexOf("BG/L job exit status =");
@@ -150,13 +150,10 @@
}
} while (line != null);
br.close();
+ wr.close();
if (caw != null) {
- caw.close();
listener.stderrUpdated(caw.toString());
}
- if (bw != null) {
- bw.close();
- }
return true;
}
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/execution/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/execution/JobSubmissionTaskHandler.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/execution/JobSubmissionTaskHandler.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -8,6 +8,7 @@
import org.apache.log4j.Logger;
import org.globus.cog.abstraction.impl.common.StatusImpl;
+import org.globus.cog.abstraction.impl.common.execution.JobException;
import org.globus.cog.abstraction.impl.common.task.IllegalSpecException;
import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException;
import org.globus.cog.abstraction.impl.common.task.InvalidServiceContactException;
@@ -16,6 +17,7 @@
import org.globus.cog.abstraction.impl.scheduler.common.Job;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessListener;
import org.globus.cog.abstraction.interfaces.DelegatedTaskHandler;
+import org.globus.cog.abstraction.interfaces.FileLocation;
import org.globus.cog.abstraction.interfaces.JobSpecification;
import org.globus.cog.abstraction.interfaces.Status;
import org.globus.cog.abstraction.interfaces.Task;
@@ -103,7 +105,7 @@
}
else {
Status s = new StatusImpl();
- s.setMessage("Process failed with exit code " + exitCode);
+ s.setException(new JobException(exitCode));
s.setStatusCode(Status.FAILED);
task.setStatus(s);
}
@@ -132,13 +134,13 @@
}
public void stderrUpdated(String stderr) {
- if (spec.isRedirected()) {
+ if (FileLocation.MEMORY.overlaps(spec.getStdErrorLocation())) {
task.setStdError(stderr);
}
}
public void stdoutUpdated(String stdout) {
- if (spec.isRedirected()) {
+ if (FileLocation.MEMORY.overlaps(spec.getStdOutputLocation())) {
task.setStdOutput(stdout);
}
}
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/Job.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/Job.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/Job.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -15,6 +15,7 @@
import java.io.IOException;
import org.apache.log4j.Logger;
+import org.globus.cog.abstraction.interfaces.FileLocation;
public class Job {
public static final Logger logger = Logger.getLogger(Job.class);
@@ -28,16 +29,19 @@
private String jobID;
private String exitcodeFileName;
private String stdout, stderr;
+ private FileLocation outLoc, errLoc;
protected ProcessListener listener;
protected int state;
private int ticks;
- public Job(String jobID, String stdout, String stderr,
+ public Job(String jobID, String stdout, FileLocation outLoc, String stderr, FileLocation errLoc,
String exitcodeFileName, ProcessListener listener) {
this.jobID = jobID;
this.listener = listener;
this.stdout = stdout;
this.stderr = stderr;
+ this.outLoc = outLoc;
+ this.errLoc = errLoc;
this.state = STATE_NONE;
this.exitcodeFileName = exitcodeFileName;
this.ticks = 0;
@@ -87,7 +91,7 @@
protected boolean processStdout() {
try {
- if (stdout != null) {
+ if (FileLocation.MEMORY.overlaps(outLoc)) {
String out = readFile(stdout);
if (out != null && !"".equals(out)) {
listener.stdoutUpdated(out);
@@ -107,7 +111,7 @@
protected boolean processStderr() {
try {
- if (stderr != null) {
+ if (FileLocation.MEMORY.overlaps(errLoc)) {
String err = readFile(stderr);
if (err != null && !"".equals(err)) {
listener.stderrUpdated(err);
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -113,8 +113,8 @@
String jobid = getOutput(process.getInputStream());
getProcessPoller().addJob(
- new Job(jobid, spec.isRedirected() ? stdout : null, spec
- .isRedirected() ? stderr : null, exitcode, this));
+ new Job(jobid, stdout, spec.getStdOutputLocation(), stderr,
+ spec.getStdErrorLocation(), exitcode, this));
}
private void error(String message) {
@@ -238,34 +238,34 @@
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == '\\') {
- if (escaped) {
- sb.append('\\');
- }
- else {
- escaped = true;
- }
+ if (escaped) {
+ sb.append('\\');
+ }
+ else {
+ escaped = true;
+ }
}
else {
if (c == '$' && !escaped) {
- if (i == str.length() - 1) {
- sb.append('$');
- }
- else {
- int e = str.indexOf(' ', i);
- if (e == -1) {
- e = str.length();
- }
- String name = str.substring(i + 1, e);
- Object attr = spec.getAttribute(name);
- if (attr != null) {
- sb.append(attr.toString());
- }
- else {
- sb.append('$');
- sb.append(name);
- }
- i = e;
- }
+ if (i == str.length() - 1) {
+ sb.append('$');
+ }
+ else {
+ int e = str.indexOf(' ', i);
+ if (e == -1) {
+ e = str.length();
+ }
+ String name = str.substring(i + 1, e);
+ Object attr = spec.getAttribute(name);
+ if (attr != null) {
+ sb.append(attr.toString());
+ }
+ else {
+ sb.append('$');
+ sb.append(name);
+ }
+ i = e;
+ }
}
else {
sb.append(c);
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java 2007-08-20 22:29:19 UTC (rev 1693)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java 2007-08-20 22:33:08 UTC (rev 1694)
@@ -8,6 +8,7 @@
import org.apache.log4j.Logger;
import org.globus.cog.abstraction.impl.common.StatusImpl;
+import org.globus.cog.abstraction.impl.common.execution.JobException;
import org.globus.cog.abstraction.impl.common.task.IllegalSpecException;
import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException;
import org.globus.cog.abstraction.impl.common.task.InvalidServiceContactException;
@@ -16,6 +17,7 @@
import org.globus.cog.abstraction.impl.scheduler.common.ProcessListener;
import org.globus.cog.abstraction.impl.scheduler.pbs.PBSExecutor;
import org.globus.cog.abstraction.interfaces.DelegatedTaskHandler;
+import org.globus.cog.abstraction.interfaces.FileLocation;
import org.globus.cog.abstraction.interfaces.JobSpecification;
import org.globus.cog.abstraction.interfaces.Status;
import org.globus.cog.abstraction.interfaces.Task;
@@ -103,7 +105,7 @@
}
else {
Status s = new StatusImpl();
- s.setMessage("Process failed with exit code " + exitCode);
+ s.setException(new JobException(exitCode));
s.setStatusCode(Status.FAILED);
task.setStatus(s);
}
@@ -132,13 +134,13 @@
}
public void stderrUpdated(String stderr) {
- if (spec.isRedirected()) {
+ if (FileLocation.MEMORY.overlaps(spec.getStdErrorLocation())) {
task.setStdError(stderr);
}
}
public void stdoutUpdated(String stdout) {
- if (spec.isRedirected()) {
+ if (FileLocation.MEMORY.overlaps(spec.getStdOutputLocation())) {
task.setStdOutput(stdout);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-08-22 18:52:04
|
Revision: 1706
http://cogkit.svn.sourceforge.net/cogkit/?rev=1706&view=rev
Author: hategan
Date: 2007-08-22 11:52:02 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
arguments
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 16:59:55 UTC (rev 1705)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 18:52:02 UTC (rev 1706)
@@ -1,3 +1,8 @@
+(08/22/07)
+
+*** The cobalt provider was not passing command line arguments
+ to the job
+
(08/20/07)
*** Redirection updates
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 16:59:55 UTC (rev 1705)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 18:52:02 UTC (rev 1706)
@@ -169,7 +169,7 @@
l.add("-E");
l.add(stderr);
l.add(spec.getExecutable());
- List args = spec.getArgumentsAsList();
+ l.addAll(spec.getArgumentsAsList());
if (logger.isDebugEnabled()) {
logger.debug("Cqsub cmd line: " + l);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-08-22 21:40:29
|
Revision: 1707
http://cogkit.svn.sourceforge.net/cogkit/?rev=1707&view=rev
Author: hategan
Date: 2007-08-22 14:40:26 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
added kernelprofile
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 18:52:02 UTC (rev 1706)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 21:40:26 UTC (rev 1707)
@@ -2,6 +2,9 @@
*** The cobalt provider was not passing command line arguments
to the job
+
+*** Added -k <kernel profile> option for cobalt. The spec attribute
+ is "kernelprofile".
(08/20/07)
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 18:52:02 UTC (rev 1706)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 21:40:26 UTC (rev 1707)
@@ -158,6 +158,7 @@
addAttr("count", "-n", l, "1");
addAttr("project", "-p", l);
addAttr("queue", "-q", l);
+ addAttr("kernelprofile", "-k", l);
// cqsub seems to require both the node count and time args
addAttr("maxwalltime", "-t", l, "10");
if (spec.getDirectory() != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-08-22 22:46:56
|
Revision: 1708
http://cogkit.svn.sourceforge.net/cogkit/?rev=1708&view=rev
Author: hategan
Date: 2007-08-22 15:46:53 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
exit code regexp
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/etc/provider-cobalt.properties
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/Properties.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 21:40:26 UTC (rev 1707)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-08-22 22:46:53 UTC (rev 1708)
@@ -5,6 +5,10 @@
*** Added -k <kernel profile> option for cobalt. The spec attribute
is "kernelprofile".
+
+*** Configurable exit code extraction regexps (Kevin Harms points
+ out that looking for a string containing "BG/L job exit status"
+ is likely to not work on a BG/P). D'oh!
(08/20/07)
Modified: trunk/current/src/cog/modules/provider-localscheduler/etc/provider-cobalt.properties
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/etc/provider-cobalt.properties 2007-08-22 21:40:26 UTC (rev 1707)
+++ trunk/current/src/cog/modules/provider-localscheduler/etc/provider-cobalt.properties 2007-08-22 22:46:53 UTC (rev 1708)
@@ -14,3 +14,15 @@
# The path to cqstat. The default assumes that cqstat is in PATH
#
cqstat=cqstat
+
+#
+# A regular expression to fetch the exit code from stderr. The
+# exit code itself should be in a capturing group (any group).
+# Use non-caputuring groups (?:X) for or-ing multiple alternatives. E.g.
+# (?:stuff ([0-9]*))|(?:some other stuff ([0-9]*))
+#
+# Backslashes need to be escaped. A literal . (dot; period) would be specified
+# as \\.
+#
+
+exitcode.regexp=(?:.*BG/. job exit status =\\s*([0-9]+))|(?:.*exit status = \\(([0-9]+)\\))
\ No newline at end of file
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 21:40:26 UTC (rev 1707)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-08-22 22:46:53 UTC (rev 1708)
@@ -18,6 +18,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessException;
@@ -36,6 +37,7 @@
private ProcessListener listener;
private String stdout, stderr;
private String cqsub;
+ private Pattern exitcodeRegexp;
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -44,6 +46,7 @@
this.spec = (JobSpecification) task.getSpecification();
this.listener = listener;
this.cqsub = Properties.getProperties().getCQSub();
+ this.exitcodeRegexp = Pattern.compile(Properties.getProperties().getExitcodeRegexp());
}
private static synchronized QueuePoller getProcessPoller() {
@@ -111,7 +114,7 @@
getProcessPoller().addJob(
new CobaltJob(jobid, stdout, stderr, spec.getStdOutput(), spec
.getStdOutputLocation(), spec.getStdError(), spec
- .getStdErrorLocation(), this));
+ .getStdErrorLocation(), exitcodeRegexp, this));
}
private void error(String message) {
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java 2007-08-22 21:40:26 UTC (rev 1707)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltJob.java 2007-08-22 22:46:53 UTC (rev 1708)
@@ -14,8 +14,9 @@
import java.io.CharArrayWriter;
import java.io.FileReader;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.Writer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import org.globus.cog.abstraction.impl.common.util.NullWriter;
@@ -31,9 +32,11 @@
private String stdout, stderr, tstdout, tstderr;
private FileLocation outLoc, errLoc;
private int exitcode;
+ private Pattern exitcodeRegexp;
- public CobaltJob(String jobID, String stdout,
- String stderr, String tstdout, FileLocation outLoc, String tstderr, FileLocation errLoc,
+ public CobaltJob(String jobID, String stdout, String stderr,
+ String tstdout, FileLocation outLoc, String tstderr,
+ FileLocation errLoc, Pattern exitcodeRegexp,
ProcessListener listener) {
super(jobID, null, null, null, null, null, listener);
this.stdout = stdout;
@@ -42,6 +45,7 @@
this.outLoc = outLoc;
this.tstderr = tstderr;
this.errLoc = errLoc;
+ this.exitcodeRegexp = exitcodeRegexp;
int exitcode = Integer.MIN_VALUE;
}
@@ -66,7 +70,8 @@
wr = caw;
}
if (tstdout != null && LOCAL_AND_REMOTE.overlaps(outLoc)) {
- wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(new FileWriter(tstdout)));
+ wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(
+ new FileWriter(tstdout)));
}
if (wr == null) {
wr = new NullWriter();
@@ -96,9 +101,10 @@
return false;
}
}
-
- private static final FileLocation LOCAL_AND_REMOTE = FileLocation.LOCAL.and(FileLocation.REMOTE);
+ private static final FileLocation LOCAL_AND_REMOTE = FileLocation.LOCAL
+ .and(FileLocation.REMOTE);
+
protected boolean processStderr() {
try {
Writer wr = null;
@@ -108,7 +114,8 @@
wr = caw;
}
if (tstdout != null && LOCAL_AND_REMOTE.overlaps(errLoc)) {
- wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(new FileWriter(tstderr)));
+ wr = WriterMultiplexer.multiplex(wr, new BufferedWriter(
+ new FileWriter(tstderr)));
}
if (wr == null) {
wr = new NullWriter();
@@ -116,7 +123,7 @@
BufferedReader br = new BufferedReader(new FileReader(stderr));
String line;
boolean started = false;
-
+
do {
line = br.readLine();
if (line != null) {
@@ -131,22 +138,31 @@
wr.write('\n');
}
else {
- int index = line.indexOf("BG/L job exit status =");
- if (index != -1) {
- String es = line.substring(index +
- "BG/L job exit status =".length()).trim();
- if (!es.startsWith("(") && !es.endsWith(")")) {
- throw new IOException(
- "Could not parse job exit status. Invalid exit status line: "
- + line);
+ Matcher m = exitcodeRegexp.matcher(line);
+ if (m.matches()) {
+ for (int i = 0; i < m.groupCount(); i++) {
+ String group = m.group(i + 1);
+ if (group != null) {
+ group = group.trim();
+ if (!group.equals("")) {
+ try {
+ exitcode = Integer
+ .parseInt(group);
+ break;
+ }
+ catch (NumberFormatException e) {
+ throw new NumberFormatException(
+ "Invalid exit status line: "
+ + line
+ + ". Could not parse job exit status: "
+ + group);
+ }
+ }
+ }
}
- else {
- exitcode = Integer.parseInt(es.substring(1, es.length() - 1));
- }
}
}
}
-
}
} while (line != null);
br.close();
@@ -154,7 +170,7 @@
if (caw != null) {
listener.stderrUpdated(caw.toString());
}
-
+
return true;
}
catch (Exception e) {
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/Properties.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/Properties.java 2007-08-22 21:40:26 UTC (rev 1707)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/Properties.java 2007-08-22 22:46:53 UTC (rev 1708)
@@ -21,7 +21,8 @@
public static final String POLL_INTERVAL = "poll.interval";
public static final String CQSUB = "cqsub";
- public static final String CQSTAT = "cqstat";
+ public static final String CQSTAT = "cqstat";
+ public static final String EXITCODE_REGEXP = "exitcode.regexp";
private static Properties properties;
@@ -52,6 +53,7 @@
setPollInterval(5);
setCQSub("cqsub");
setCQStat("cqstat");
+ setExitcodeRegexp("(?BG/L job exit status = ([0-9]+))|(?exit status = \\(([0-9]+)\\))");
}
public void setPollInterval(int value) {
@@ -77,4 +79,12 @@
public String getCQStat() {
return getProperty(CQSTAT);
}
+
+ public String getExitcodeRegexp() {
+ return getProperty(EXITCODE_REGEXP);
+ }
+
+ public void setExitcodeRegexp(String value) {
+ setProperty(EXITCODE_REGEXP, value);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-09-19 15:43:53
|
Revision: 1744
http://cogkit.svn.sourceforge.net/cogkit/?rev=1744&view=rev
Author: hategan
Date: 2007-09-19 08:43:47 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
correctly map count to -c and host count to -n
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-09-19 15:36:47 UTC (rev 1743)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2007-09-19 15:43:47 UTC (rev 1744)
@@ -1,3 +1,13 @@
+(09/19/07)
+
+*** Cobalt: 'count' attribute mapped to '-c'. The default should
+ be figured by cqsub from 'hostCount'. Looking at the cqsub
+ code, it seems like count = 2 * hostCount on a BG/L and
+ count = 4 * hostCount on a BG/P.
+
+*** Cobalt: 'hostCount' attribute mapped to '-n', with a default
+ of 1
+
(08/22/07)
*** The cobalt provider was not passing command line arguments
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-09-19 15:36:47 UTC (rev 1743)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/cobalt/CobaltExecutor.java 2007-09-19 15:43:47 UTC (rev 1744)
@@ -158,7 +158,8 @@
}
addAttr("mode", "-m", l);
// We're gonna treat this as the node count
- addAttr("count", "-n", l, "1");
+ addAttr("count", "-c", l);
+ addAttr("hostCount", "-n", l, "1");
addAttr("project", "-p", l);
addAttr("queue", "-q", l);
addAttr("kernelprofile", "-k", l);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-04-25 02:10:21
|
Revision: 1987
http://cogkit.svn.sourceforge.net/cogkit/?rev=1987&view=rev
Author: hategan
Date: 2008-04-24 19:10:10 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
added job canceling to pbs provider
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/Properties.java
trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java
Modified: trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2008-04-25 00:57:55 UTC (rev 1986)
+++ trunk/current/src/cog/modules/provider-localscheduler/CHANGES.txt 2008-04-25 02:10:10 UTC (rev 1987)
@@ -1,3 +1,7 @@
+(04/24/08)
+
+*** Added job canceling to PBS
+
(09/19/07)
*** Cobalt: 'count' attribute mapped to '-c'. The default should
Modified: trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties 2008-04-25 00:57:55 UTC (rev 1986)
+++ trunk/current/src/cog/modules/provider-localscheduler/etc/provider-pbs.properties 2008-04-25 02:10:10 UTC (rev 1987)
@@ -15,7 +15,12 @@
#
qstat=qstat
+#
+# The path to qdel. The default assumes that qdel is in PATH
+#
+qdel=qdel
+
#
# If the jobType attribute is specified, then the PBS provider
# will look for a property named "wrapper.<jobType>" and prepend
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2008-04-25 00:57:55 UTC (rev 1986)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/PBSExecutor.java 2008-04-25 02:10:10 UTC (rev 1987)
@@ -21,6 +21,7 @@
import java.util.List;
import org.apache.log4j.Logger;
+import org.globus.cog.abstraction.impl.common.task.TaskSubmissionException;
import org.globus.cog.abstraction.impl.scheduler.common.Job;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessException;
import org.globus.cog.abstraction.impl.scheduler.common.ProcessListener;
@@ -36,10 +37,10 @@
private Task task;
private static QueuePoller poller;
private ProcessListener listener;
- private String stdout, stderr, exitcode;
+ private String stdout, stderr, exitcode, jobid;
private File script;
private static boolean debug;
-
+
static {
debug = "true".equals(Properties.getProperties().getProperty("debug"));
}
@@ -116,7 +117,7 @@
}
}
- String jobid = getOutput(process.getInputStream());
+ jobid = getOutput(process.getInputStream());
process.getInputStream().close();
getProcessPoller().addJob(
@@ -124,6 +125,31 @@
spec.getStdErrorLocation(), exitcode, this));
}
+ public void cancel() throws TaskSubmissionException {
+ if (jobid == null) {
+ throw new TaskSubmissionException("Can only cancel an active task");
+ }
+ String[] cmdline = new String[] { Properties.getProperties().getQDel(),
+ jobid };
+ try {
+ System.out.println("Canceling job " + jobid);
+ Process process = Runtime.getRuntime().exec(cmdline, null, null);
+ int ec = process.waitFor();
+ if (ec != 0) {
+ throw new TaskSubmissionException(
+ "Failed to cancel task. qdel returned with an exit code of "
+ + ec);
+ }
+ }
+ catch (InterruptedException e) {
+ throw new TaskSubmissionException(
+ "Thread interrupted while waiting for qdel to finish");
+ }
+ catch (IOException e) {
+ throw new TaskSubmissionException("Failed to cancel task", e);
+ }
+ }
+
private void error(String message) {
listener.processFailed(message);
}
@@ -197,9 +223,9 @@
wr.write("/bin/echo $? >" + exitcodefile + '\n');
wr.close();
}
-
+
private static final boolean[] TRIGGERS;
-
+
static {
TRIGGERS = new boolean[128];
TRIGGERS[' '] = true;
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/Properties.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/Properties.java 2008-04-25 00:57:55 UTC (rev 1986)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/Properties.java 2008-04-25 02:10:10 UTC (rev 1987)
@@ -21,7 +21,8 @@
public static final String POLL_INTERVAL = "poll.interval";
public static final String QSUB = "qsub";
- public static final String QSTAT = "qstat";
+ public static final String QSTAT = "qstat";
+ public static final String QDEL = "qdel";
private static Properties properties;
@@ -52,6 +53,7 @@
setPollInterval(5);
setQSub("qsub");
setQStat("qstat");
+ setQDel("qdel");
}
public void setPollInterval(int value) {
@@ -77,4 +79,12 @@
public String getQStat() {
return getProperty(QSTAT);
}
+
+ public String getQDel() {
+ return getProperty(QDEL);
+ }
+
+ public void setQDel(String qdel) {
+ setProperty(QDEL, qdel);
+ }
}
Modified: trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java 2008-04-25 00:57:55 UTC (rev 1986)
+++ trunk/current/src/cog/modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/pbs/execution/JobSubmissionTaskHandler.java 2008-04-25 02:10:10 UTC (rev 1987)
@@ -31,6 +31,7 @@
private Task task;
private JobSpecification spec;
private Thread thread;
+ private PBSExecutor executor;
public void submit(Task task) throws IllegalSpecException,
InvalidSecurityContextException, InvalidServiceContactException,
@@ -60,7 +61,8 @@
try {
synchronized(this) {
if (this.task.getStatus().getStatusCode() != Status.CANCELED) {
- new PBSExecutor(task, this).start();
+ executor = new PBSExecutor(task, this);
+ executor.start();
this.task.setStatus(Status.SUBMITTED);
if (spec.isBatchJob()) {
this.task.setStatus(Status.COMPLETED);
@@ -90,7 +92,7 @@
public synchronized void cancel() throws InvalidSecurityContextException,
TaskSubmissionException {
- //TODO actually cancel the job
+ executor.cancel();
this.task.setStatus(Status.CANCELED);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|