Revision: 13775
http://gate.svn.sourceforge.net/gate/?rev=13775&view=rev
Author: ian_roberts
Date: 2011-04-28 10:34:38 +0000 (Thu, 28 Apr 2011)
Log Message:
-----------
Added a true-by-default flag telling the BatchRunner to do a hard System.exit
when it has no more batches to process. This is a quick fix for a problem
where certain PRs and LRs (notably the OWLIM Ontology) can leave idle
non-daemon background threads when the batch completes, preventing the GCP
process from exiting. The PRs making up the application are all properly
disposed at the end of the batch but the other PRs and/or LRs they depend on
may not be.
Modified Paths:
--------------
gcp/trunk/src/gate/cloud/batch/BatchRunner.java
Modified: gcp/trunk/src/gate/cloud/batch/BatchRunner.java
===================================================================
--- gcp/trunk/src/gate/cloud/batch/BatchRunner.java 2011-04-28 01:14:39 UTC
(rev 13774)
+++ gcp/trunk/src/gate/cloud/batch/BatchRunner.java 2011-04-28 10:34:38 UTC
(rev 13775)
@@ -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