|
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.
|