From: Sasha Date: Mon, 29 Jul 2013 11:57:42 +0000 (+0100) Subject: Improve shutdown of JABAWS and some code style improvements X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6af395c1326bb7150f295c8266530158d9fc8755;p=jabaws.git Improve shutdown of JABAWS and some code style improvements --- diff --git a/webservices/compbio/ws/server/MainManager.java b/webservices/compbio/ws/server/MainManager.java index 54f1daf..632ceeb 100644 --- a/webservices/compbio/ws/server/MainManager.java +++ b/webservices/compbio/ws/server/MainManager.java @@ -33,7 +33,6 @@ import compbio.engine.conf.PropertyHelperManager; import compbio.engine.local.ExecutableWrapper; import compbio.engine.local.LocalExecutorService; import compbio.util.PropertyHelper; -import compbio.util.Util; /** * Two tasks: @@ -56,24 +55,26 @@ public class MainManager implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent ignored) { // stop cleaning job directories -// try { + try { if (null != localcl) { localcl.cancel(true); } if (null != clustercl) { clustercl.cancel(true); } - //executor.shutdown(); - //executor.awaitTermination(3, TimeUnit.SECONDS); -// } catch (InterruptedException e) { -// log.warn(e.getMessage(), e); -// } - // Shutdown local engine - log.info("JABAWS context is destroyed. Shutting down engines..."); - LocalExecutorService.shutDown(); - log.info("Local engine is shutdown OK"); - ExecutableWrapper.shutdownService(); - log.info("Individual executables stream engine is shutdown OK"); + executor.shutdown(); + executor.awaitTermination(3, TimeUnit.SECONDS); + } catch (InterruptedException e) { + log.warn(e.getMessage(), e); + } + + // Shutdown local and cluster engines + log.info("JABAWS context is destroyed. Shutting down engines..."); + LocalExecutorService.shutDown(); + log.info("Local engine is shutdown OK"); + ExecutableWrapper.shutdownService(); + log.info("Individual executables stream engine is shutdown OK"); + StatDB.shutdownDBServer(); } @Override @@ -88,7 +89,7 @@ public class MainManager implements ServletContextListener { boolean cleanClasterDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("cluster.stat.collector.enable")); if (0 < clusterDirLifespan && cleanClasterDir) { - DirCleaner clusterDirCleaner = new DirCleaner( clusterWorkDir, clusterDirLifespan); + DirCleaner clusterDirCleaner = new DirCleaner(clusterWorkDir, clusterDirLifespan); clustercl = executor.scheduleAtFixedRate(clusterDirCleaner, 1, clusterCleaningRate, TimeUnit.MINUTES); log.info("Cleaning local job directory every " + clusterCleaningRate + " minutes"); } else { @@ -102,7 +103,7 @@ public class MainManager implements ServletContextListener { boolean cleanLocalDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("local.stat.collector.enable")); if (0 < localDirLiveSpan && cleanLocalDir) { - DirCleaner localDirCleaner = new DirCleaner( localWorkDir, localDirLiveSpan); + DirCleaner localDirCleaner = new DirCleaner(localWorkDir, localDirLiveSpan); localcl = executor.scheduleAtFixedRate(localDirCleaner, 1, localCleaningRate, TimeUnit.MINUTES); log.info("Cleaning local job directory every " + localCleaningRate + " minutes"); } else {