Revision: 13776
http://gate.svn.sourceforge.net/gate/?rev=13776&view=rev
Author: ian_roberts
Date: 2011-04-28 10:37:42 +0000 (Thu, 28 Apr 2011)
Log Message:
-----------
Merged exitWhenFinished patch from trunk.
Modified Paths:
--------------
gcp/branches/2.0/src/gate/cloud/batch/BatchRunner.java
Property Changed:
----------------
gcp/branches/2.0/
Property changes on: gcp/branches/2.0
___________________________________________________________________
Added: svn:mergeinfo
+ /gcp/trunk:13775
Modified: gcp/branches/2.0/src/gate/cloud/batch/BatchRunner.java
===================================================================
--- gcp/branches/2.0/src/gate/cloud/batch/BatchRunner.java 2011-04-28
10:34:38 UTC (rev 13775)
+++ gcp/branches/2.0/src/gate/cloud/batch/BatchRunner.java 2011-04-28
10:37:42 UTC (rev 13776)
@@ -271,9 +271,10 @@
/**
* A thread that runs continuously while the batch runner is active. Its role
* is to monitor the running jobs, collect process results, save the report
- * files for each running batch, and shutdown the batch runner when all the
- * batches have completed (if requested via the
- * {@link BatchRunner#shutdownWhenFinished(boolean)} method).
+ * files for each running batch, and shutdown the batch runner and/or Java
+ * process when all the batches have completed (if requested via the
+ * {@link BatchRunner#shutdownWhenFinished(boolean)} and
+ * {@link BatchRunner#exitWhenFinished(boolean)} methods).
*/
private class JobMonitor implements Runnable {
public void run() {
@@ -331,9 +332,14 @@
}
}
// if all jobs finished and we should shutdown, then let's shutdown
- if(shutdownWhenFinished && !jobsStillRunning) {
- shutdown();
- finished = true;
+ if(!jobsStillRunning) {
+ if(shutdownWhenFinished) {
+ shutdown();
+ finished = true;
+ }
+ if(exitWhenFinished) {
+ System.exit(0);
+ }
}
long remainingSleepTime = LOOP_WAIT
- (System.currentTimeMillis() - startTime);
@@ -373,6 +379,12 @@
}
}
+ public void exitWhenFinished(boolean flag) {
+ synchronized(this) {
+ this.exitWhenFinished = flag;
+ }
+ }
+
/**
* Stops this batch runner in an orderly fashion.
*/
@@ -406,6 +418,11 @@
* currently running batches have completed.
*/
private boolean shutdownWhenFinished = true;
+ /**
+ * A flag used to signal that the batch runner should exit the Java process
+ * when all currently running batches have completed.
+ */
+ private boolean exitWhenFinished = true;
/**
* Starts executing the batch task specified by the provided parameter.
@@ -536,6 +553,7 @@
log.info("Launching batch:\n" + aBatch);
instance.runBatch(aBatch);
instance.shutdownWhenFinished(true);
+ instance.exitWhenFinished(true);
} catch(Exception e) {
log.error("Error starting up batch " + batchFile, e);
System.exit(1);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs