From 72f8e583b6884a32f6731bf6f16cd6470a2b5c06 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Thu, 29 Dec 2016 17:54:25 +0200 Subject: [PATCH] Save cluster sets only when creating DB snapshots 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 --- .../src/org/simantics/acorn/ClusterManager.java | 10 +++++----- .../simantics/procore/internal/TransactionToken.java | 6 ------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java index b2a30953c..3cbb64977 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java @@ -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); diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java index 753023641..d5f5c4308 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java @@ -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) -- 2.43.2