From: jsimomaa Date: Mon, 26 Nov 2018 20:15:33 +0000 (+0200) Subject: Move shutdown of worker pools to SimanticsPlatform.shutdown() X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ab95cc6c2e77d8433f50b6438474b543bb029cf7;p=simantics%2Fplatform.git Move shutdown of worker pools to SimanticsPlatform.shutdown() 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) --- diff --git a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java index 80f2eee0a..f590b5e0e 100644 --- a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java +++ b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java @@ -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 { diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 8b1ac1bce..1f367dc9a 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -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 {