|
From: <ha...@us...> - 2008-02-12 17:29:15
|
Revision: 1892
http://cogkit.svn.sourceforge.net/cogkit/?rev=1892&view=rev
Author: hategan
Date: 2008-02-12 09:29:05 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
fixed cancelling and weird status checks: if you want to see if it was canceled then don't check if it's unsubmitted; those are two different things
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-local/src/org/globus/cog/abstraction/impl/execution/local/JobSubmissionTaskHandler.java
Modified: trunk/current/src/cog/modules/provider-local/src/org/globus/cog/abstraction/impl/execution/local/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-local/src/org/globus/cog/abstraction/impl/execution/local/JobSubmissionTaskHandler.java 2008-02-12 17:27:23 UTC (rev 1891)
+++ trunk/current/src/cog/modules/provider-local/src/org/globus/cog/abstraction/impl/execution/local/JobSubmissionTaskHandler.java 2008-02-12 17:29:05 UTC (rev 1892)
@@ -54,8 +54,13 @@
if (this.task != null) {
throw new TaskSubmissionException(
"JobSubmissionTaskHandler cannot handle two active jobs simultaneously");
- } else {
+ }
+ else if (this.task.getStatus().getStatusCode() != Status.UNSUBMITTED) {
+ throw new TaskSubmissionException("Task is not in unsubmitted state");
+ }
+ else {
this.task = task;
+ task.setStatus(Status.SUBMITTING);
JobSpecification spec;
try {
spec = (JobSpecification) this.task.getSpecification();
@@ -72,14 +77,14 @@
if (logger.isInfoEnabled()) {
logger.info("Submitting task " + task);
}
- this.thread = new Thread(this);
- // check if the task has not been canceled after it was
- // submitted for execution
- if (this.task.getStatus().getStatusCode() == Status.UNSUBMITTED) {
- this.task.setStatus(Status.SUBMITTED);
- this.thread.start();
- if (spec.isBatchJob()) {
- this.task.setStatus(Status.COMPLETED);
+ synchronized(this) {
+ this.thread = new Thread(this);
+ if (this.task.getStatus().getStatusCode() != Status.CANCELED) {
+ this.task.setStatus(Status.SUBMITTED);
+ this.thread.start();
+ if (spec.isBatchJob()) {
+ this.task.setStatus(Status.COMPLETED);
+ }
}
}
} catch (Exception e) {
@@ -98,9 +103,11 @@
public void cancel() throws InvalidSecurityContextException,
TaskSubmissionException {
- killed = true;
- process.destroy();
- this.task.setStatus(Status.CANCELED);
+ synchronized(this) {
+ killed = true;
+ process.destroy();
+ this.task.setStatus(Status.CANCELED);
+ }
}
private static final FileLocation REDIRECT_LOCATION = FileLocation.MEMORY
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|