]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Save cluster sets only when creating DB snapshots 40/240/3
authorJussi Koskela <jussi.koskela@semantum.fi>
Thu, 29 Dec 2016 15:54:25 +0000 (17:54 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 2 Jan 2017 10:19:40 +0000 (13:19 +0300)
Performance improvement. Also fix the order of saving cluster sets and
persisting head state. This (luckily) worked correctly earlier as well,
since the cluster sets were saved after each change.

refs #6904
Change-Id: I67f238f8060672a99160a85bdbd2703d94fa275b

bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java

index b2a30953cca9e0bff26e72dc69a788139e52a817..3cbb64977ae203d3f55efa879e8ec56331477be6 100644 (file)
@@ -143,7 +143,7 @@ public class ClusterManager {
                // Cluster files are always there 
                // Nothing has been written => no need to do anything
                long amountOfFiles = countFiles(workingDirectory);
-               if(!fullSave && amountOfFiles < 3) {
+               if(!fullSave && amountOfFiles == 0) {
     //             System.err.println("amountOfFiles < 3");
                    return false;
                }
@@ -163,14 +163,14 @@ public class ClusterManager {
                if (!safeToMakeSnapshot.get())
                    throw cause;
                
+               ClusterSetsSupport cssi = locator.getService(ClusterSetsSupport.class); 
+               cssi.save();
+
                persistHeadState();
-               
+
                if (fullSave)
                    mainState.save(dbFolder);
     
-               ClusterSetsSupport cssi = locator.getService(ClusterSetsSupport.class); 
-               cssi.save();
-    
                amountOfFiles = countFiles(workingDirectory);
                
                System.err.println(" -finished: amount of files is " + amountOfFiles);
index 753023641197617f87419e361e1f976f2f34688f..d5f5c4308903cdd6aee7d0a5c3dbed5ffe1f40a2 100644 (file)
@@ -213,12 +213,6 @@ public class TransactionToken implements GraphSession.Listener {
         else if (Type.Read == type)
             throw new ValidationException("Illegal transaction type.");
         // Note that even if we do cancel the cluster sets are not restored.
-        try {
-            session.getService(ClusterSetsSupport.class).save();
-        } catch (Exception e) {
-            e.printStackTrace();
-            Logger.defaultLogError("Failed to save cluster sets.", e);
-        }
         graphSession.undoContext.cancelCommit();
         endTransaction(true);
         if (DEBUG)