]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Move shutdown of worker pools to SimanticsPlatform.shutdown() 37/2537/2
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 26 Nov 2018 20:15:33 +0000 (22:15 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Mon, 10 Dec 2018 08:34:59 +0000 (08:34 +0000)
Closing of public worker pools should be done before we are closing our
db-connection. The platform-shutdown routine has already started and
therefore it should not be meaningful to execute any more work for a
closing platform

gitlab #212

Change-Id: I9fb8fb0970d649f7b53282be0627bf5387c9dde9
(cherry picked from commit 502db54a267e8583aef1f57120ddc9ac162fbba9)

bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index 80f2eee0a2184494c4477e674ed3b704112d2bf8..f590b5e0e82c6dc2dc1f798259c196c8d9178ba7 100644 (file)
@@ -98,7 +98,6 @@ import org.simantics.db.common.Indexing;
 import org.simantics.db.indexing.DatabaseIndexing;
 import org.simantics.db.procore.server.environment.RebootRequiredException;
 import org.simantics.db.procore.server.environment.windows.Product;
-import org.simantics.internal.TimedSessionCache;
 import org.simantics.project.IProject;
 import org.simantics.project.ProjectKeys;
 import org.simantics.ui.SimanticsUI;
@@ -106,8 +105,6 @@ import org.simantics.ui.jobs.SessionGarbageCollectorJob;
 import org.simantics.ui.workbench.PerspectiveBarsActivator;
 import org.simantics.ui.workbench.PerspectiveContextActivator;
 import org.simantics.utils.logging.TimeLogger;
-import org.simantics.utils.threads.ExecutorWorker;
-import org.simantics.utils.threads.ThreadUtils;
 import org.simantics.utils.ui.dialogs.ShowError;
 import org.simantics.utils.ui.dialogs.ShowMessage;
 import org.slf4j.Logger;
@@ -737,30 +734,13 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
             try {
                 try {
                     progress.subTask("Platform");
-                    SimanticsPlatform.INSTANCE.shutdown(progress.newChild(50));
+                    SimanticsPlatform.INSTANCE.shutdown(progress.newChild(100));
                 } catch (PlatformException e) {
                     Activator.logError("Problems encountered while shutting down Simantics platform, see exception for details.", e);
                 }
 
                 progress.subTask("Remaining database connections");
                 SimanticsUI.closeSessions();
-                progress.worked(20);
-                TimedSessionCache.close();
-                progress.worked(20);
-
-                progress.subTask("Thread pools");
-                ThreadUtils.shutdown();
-                ExecutorWorker.shutdown();
-                progress.worked(5);
-
-                progress.subTask("Clear index status");
-                try {
-                    // Everything ok, clear index dirty state.
-                    DatabaseIndexing.clearAllDirty();
-                } catch (IOException e) {
-                    Activator.logError("Problems encountered while refreshing database index states, see exception for details.", e);
-                }
-                progress.worked(5);
 
                 progress.setWorkRemaining(0);
             } finally {
index 8b1ac1bced1659d414c17dbf6930b11500bbed2b..1f367dc9abf83d63c8201a95d000145ff8f5d3fe 100644 (file)
@@ -91,6 +91,7 @@ import org.simantics.graph.db.TransferableGraphs;
 import org.simantics.graph.diff.Diff;
 import org.simantics.graph.diff.TransferableGraphDelta1;
 import org.simantics.internal.Activator;
+import org.simantics.internal.TimedSessionCache;
 import org.simantics.internal.startup.StartupExtensions;
 import org.simantics.layer0.Layer0;
 import org.simantics.operation.Layer0X;
@@ -113,6 +114,8 @@ import org.simantics.utils.FileUtils;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.logging.TimeLogger;
 import org.simantics.utils.strings.EString;
+import org.simantics.utils.threads.ExecutorWorker;
+import org.simantics.utils.threads.ThreadUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -973,6 +976,14 @@ public class SimanticsPlatform implements LifecycleListener {
             }
             progress.worked(10);
 
+            // NOP at the moment
+            TimedSessionCache.close();
+
+            progress.subTask("Thread pools");
+            ThreadUtils.shutdown();
+            ExecutorWorker.shutdown();
+            progress.worked(5);
+
             running = false;
             progress.subTask("Close Database Session");
             if (sessionContext != null) {
@@ -999,7 +1010,7 @@ public class SimanticsPlatform implements LifecycleListener {
             // Make sure Simantics clipboard doesn't store unwanted session data references.
             Simantics.setClipboard(new SimanticsClipboardImpl());
 
-            progress.worked(30);
+            progress.worked(50);
 
             session = null;
             projectResource = null;
@@ -1021,6 +1032,15 @@ public class SimanticsPlatform implements LifecycleListener {
         }
         progress.worked(10);
 
+        progress.subTask("Clear index status");
+        try {
+            // Everything ok, clear index dirty state.
+            DatabaseIndexing.clearAllDirty();
+        } catch (IOException e) {
+            LOGGER.error("Problems encountered while refreshing database index states, see exception for details.", e);
+        }
+        progress.worked(5);
+
         if (clearTemporaryFiles) {
             progress.subTask("Clearing Workspace Temporary Directory");
             try {