Improve shutdown of JABAWS and some code style improvements
authorSasha <Main-laptop2>
Mon, 29 Jul 2013 11:57:42 +0000 (12:57 +0100)
committerSasha <Main-laptop2>
Mon, 29 Jul 2013 11:57:42 +0000 (12:57 +0100)
webservices/compbio/ws/server/MainManager.java

index 54f1daf..632ceeb 100644 (file)
@@ -33,7 +33,6 @@ import compbio.engine.conf.PropertyHelperManager;
 import compbio.engine.local.ExecutableWrapper;\r
 import compbio.engine.local.LocalExecutorService;\r
 import compbio.util.PropertyHelper;\r
-import compbio.util.Util;\r
 \r
 /**\r
  * Two tasks:\r
@@ -56,24 +55,26 @@ public class MainManager implements ServletContextListener {
        @Override\r
        public void contextDestroyed(ServletContextEvent ignored) {\r
                // stop cleaning job directories\r
-//             try {\r
+               try {\r
                        if (null != localcl) {\r
                                localcl.cancel(true);\r
                        }\r
                        if (null != clustercl) {\r
                                clustercl.cancel(true);\r
                        }\r
-                       //executor.shutdown();\r
-                       //executor.awaitTermination(3, TimeUnit.SECONDS);\r
-//             } catch (InterruptedException e) {\r
-//                     log.warn(e.getMessage(), e);\r
-//             }\r
-               // Shutdown local engine\r
-               log.info("JABAWS context is destroyed. Shutting down engines...");\r
-               LocalExecutorService.shutDown();\r
-               log.info("Local engine is shutdown OK");\r
-               ExecutableWrapper.shutdownService();\r
-               log.info("Individual executables stream engine is shutdown OK");\r
+                       executor.shutdown();\r
+                       executor.awaitTermination(3, TimeUnit.SECONDS);\r
+               } catch (InterruptedException e) {\r
+                       log.warn(e.getMessage(), e);\r
+               }\r
+\r
+                       // Shutdown local and cluster engines\r
+                       log.info("JABAWS context is destroyed. Shutting down engines...");\r
+                       LocalExecutorService.shutDown();\r
+                       log.info("Local engine is shutdown OK");\r
+                       ExecutableWrapper.shutdownService();\r
+                       log.info("Individual executables stream engine is shutdown OK");\r
+                       StatDB.shutdownDBServer();\r
        }\r
 \r
        @Override\r
@@ -88,7 +89,7 @@ public class MainManager implements ServletContextListener {
                boolean cleanClasterDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("cluster.stat.collector.enable"));\r
                \r
                if (0 < clusterDirLifespan && cleanClasterDir) {\r
-                       DirCleaner clusterDirCleaner = new DirCleaner(  clusterWorkDir, clusterDirLifespan);\r
+                       DirCleaner clusterDirCleaner = new DirCleaner(clusterWorkDir, clusterDirLifespan);\r
                        clustercl = executor.scheduleAtFixedRate(clusterDirCleaner, 1, clusterCleaningRate, TimeUnit.MINUTES);\r
                        log.info("Cleaning local job directory every " + clusterCleaningRate + " minutes");\r
                } else {\r
@@ -102,7 +103,7 @@ public class MainManager implements ServletContextListener {
                boolean cleanLocalDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("local.stat.collector.enable"));\r
 \r
                if (0 < localDirLiveSpan && cleanLocalDir) {\r
-                       DirCleaner localDirCleaner = new DirCleaner(    localWorkDir, localDirLiveSpan);\r
+                       DirCleaner localDirCleaner = new DirCleaner(localWorkDir, localDirLiveSpan);\r
                        localcl = executor.scheduleAtFixedRate(localDirCleaner, 1, localCleaningRate, TimeUnit.MINUTES);\r
                        log.info("Cleaning local job directory every " + localCleaningRate + " minutes");\r
                } else {\r