X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2FGraphClientImpl2.java;h=07fe18e61201cc16fd4e62bd62b808d8d6b5041d;hb=06ee0c4c71cd9e372969da1570e7fcac2c4397a5;hp=acf8b6e659bfe7de8393b4a046ab32b365bc300d;hpb=f9b0a9c48dd040142414f8d3e7ac43b502d3e203;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java index acf8b6e65..07fe18e61 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java @@ -27,14 +27,13 @@ import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.acorn.internal.ClusterChange; import org.simantics.acorn.internal.ClusterUpdateProcessorBase; import org.simantics.acorn.internal.UndoClusterUpdateProcessor; +import org.simantics.acorn.lru.ClusterChangeSet.Entry; import org.simantics.acorn.lru.ClusterInfo; import org.simantics.acorn.lru.ClusterStreamChunk; import org.simantics.acorn.lru.ClusterUpdateOperation; -import org.simantics.acorn.lru.ClusterChangeSet.Entry; import org.simantics.db.ClusterCreator; import org.simantics.db.Database; import org.simantics.db.ServiceLocator; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.SDBException; import org.simantics.db.server.ProCoreException; @@ -43,11 +42,14 @@ import org.simantics.db.service.ClusterUID; import org.simantics.db.service.LifecycleSupport; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.logging.TimeLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.TLongObjectHashMap; public class GraphClientImpl2 implements Database.Session { - + + private static final Logger LOGGER = LoggerFactory.getLogger(GraphClientImpl2.class); public static final boolean DEBUG = false; public final ClusterManager clusters; @@ -124,10 +126,10 @@ public class GraphClientImpl2 implements Database.Session { mainProgram.mutex.release(); } } catch (IllegalAcornStateException | ProCoreException e) { - Logger.defaultLogError("Snapshotting failed", e); + LOGGER.error("Snapshotting failed", e); unexpectedClose = true; } catch (InterruptedException e) { - Logger.defaultLogError("Snapshotting interrupted", e); + LOGGER.error("Snapshotting interrupted", e); } finally { try { if(tr != null) @@ -137,11 +139,11 @@ public class GraphClientImpl2 implements Database.Session { try { support.close(); } catch (DatabaseException e1) { - Logger.defaultLogError("Failed to close database as a safety measure due to failed snapshotting", e1); + LOGGER.error("Failed to close database as a safety measure due to failed snapshotting", e1); } } } catch (ProCoreException e) { - Logger.defaultLogError("Failed to end snapshotting write transaction", e); + LOGGER.error("Failed to end snapshotting write transaction", e); } } } @@ -184,13 +186,13 @@ public class GraphClientImpl2 implements Database.Session { @Override public void close() throws ProCoreException { - System.err.println("Closing " + this + " and mainProgram " + mainProgram); + LOGGER.info("Closing " + this + " and mainProgram " + mainProgram); if(!closed && !isClosing) { isClosing = true; try { if (!unexpectedClose) makeSnapshot(true); - + mainProgram.close(); clusters.shutdown(); executor.shutdown(); @@ -199,7 +201,13 @@ public class GraphClientImpl2 implements Database.Session { boolean saverTerminated = saver.awaitTermination(500, TimeUnit.MILLISECONDS); System.err.println("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated); - + + try { + clusters.mainState.save(dbFolder); + } catch (IOException e) { + LOGGER.error("Failed to save " + MainState.MAIN_STATE + " file in database folder " + dbFolder); + } + mainProgram = null; executor = null; saver = null; @@ -249,7 +257,7 @@ public class GraphClientImpl2 implements Database.Session { clusters.state.headChangeSetId++; return clusters.state.headChangeSetId; } catch (SDBException e) { - Logger.defaultLogError("Failed to undo cancelled transaction", e); + LOGGER.error("Failed to undo cancelled transaction", e); throw new ProCoreException(e); } } @@ -758,10 +766,10 @@ public class GraphClientImpl2 implements Database.Session { mainProgram.mutex.release(); } } catch (IllegalAcornStateException | ProCoreException e) { - Logger.defaultLogError("Purge failed", e); + LOGGER.error("Purge failed", e); unexpectedClose = true; } catch (InterruptedException e) { - Logger.defaultLogError("Purge interrupted", e); + LOGGER.error("Purge interrupted", e); } finally { try { if(tr != null) @@ -771,11 +779,11 @@ public class GraphClientImpl2 implements Database.Session { try { support.close(); } catch (DatabaseException e1) { - Logger.defaultLogError("Failed to close database as a safety measure due to failed purge", e1); + LOGGER.error("Failed to close database as a safety measure due to failed purge", e1); } } } catch (ProCoreException e) { - Logger.defaultLogError("Failed to end purge write transaction", e); + LOGGER.error("Failed to end purge write transaction", e); } } }