From 54473e30e21abd83d47c14b4252a688ad944142e Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Tue, 27 Sep 2016 14:00:54 +0300 Subject: [PATCH] DB-client fixes * XSupport.rollback for checking if database rolled back * Separate read and write directory setting and updating in ClusterSetsSupport refs #6710 Change-Id: I3395c7042ab3faf2291ed215d4e5830d80b6d2fa --- .../procore/internal/ClusterSetsSupportImpl.java | 7 ++++++- .../procore/internal/ClusterSetsSupportImpl2.java | 14 +++++++------- .../procore/internal/GraphSessionVirtual.java | 5 +++++ .../procore/internal/SessionImplSocket.java | 3 ++- .../org/simantics/db/server/internal/SessionI.java | 5 +++++ .../src/org/simantics/db/Database.java | 1 + .../simantics/db/service/ClusterSetsSupport.java | 3 ++- 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl.java index c20304095..da2c88f21 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl.java @@ -70,8 +70,13 @@ public class ClusterSetsSupportImpl implements ClusterSetsSupport, Disposable { clusterSets.clear(); } @Override - public void updateReadAndWriteDirectories(Path read, Path write) { + public void updateWriteDirectory(Path write) { // Nothing to do here } + @Override + public void setReadDirectory(Path read) { + + } + } diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl2.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl2.java index def2905e3..ed1689ea4 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl2.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl2.java @@ -70,17 +70,17 @@ public class ClusterSetsSupportImpl2 implements ClusterSetsSupport, Disposable { clusterSets.clear(); } @Override - public void updateReadAndWriteDirectories(Path read, Path write) { - setDirectories(read, write); - } - - private void setDirectories(Path readDirectory, Path writeDirectory) { - this.readDirectory = readDirectory; - this.writeDirectory = writeDirectory; + public void updateWriteDirectory(Path write) { + this.writeDirectory = write; if(clusterSets != null) { clusterSets.setWriteDirectory(writeDirectory.toFile()); clusterSets.touch(); } } + + @Override + public void setReadDirectory(Path read) { + this.readDirectory = read; + } } diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionVirtual.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionVirtual.java index 6defe634a..d1e006424 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionVirtual.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionVirtual.java @@ -127,6 +127,11 @@ class GraphSessionVirtual extends GraphSession { // Äsh! This extends relation public boolean refreshEnabled() { return false; } + @Override + public boolean rolledback() { + // TODO Auto-generated method stub + return false; + } } private AtomicLong changeSetId = new AtomicLong(Constants.NullChangeSetId); private AtomicLong transactionId = new AtomicLong(Constants.NullTransactionId); diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java index 9efb0fc38..7302d13d4 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java @@ -294,7 +294,8 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule this.clusterControl = new ClusterControlImpl(this); serviceLocator.registerService(ClusterControl.class, clusterControl); this.clusterSetsSupport = new ClusterSetsSupportImpl2(); // Using same path as virtual graphs. - this.clusterSetsSupport.updateReadAndWriteDirectories(t.toPath(), t.toPath()); + this.clusterSetsSupport.setReadDirectory(t.toPath()); + this.clusterSetsSupport.updateWriteDirectory(t.toPath()); serviceLocator.registerService(ClusterSetsSupport.class, clusterSetsSupport); } diff --git a/bundles/org.simantics.db.server/src/org/simantics/db/server/internal/SessionI.java b/bundles/org.simantics.db.server/src/org/simantics/db/server/internal/SessionI.java index bb2cdb040..2d08de4a6 100644 --- a/bundles/org.simantics.db.server/src/org/simantics/db/server/internal/SessionI.java +++ b/bundles/org.simantics.db.server/src/org/simantics/db/server/internal/SessionI.java @@ -232,6 +232,11 @@ public class SessionI implements Session { public boolean refreshEnabled() { return true; } + @Override + public boolean rolledback() { + // TODO Auto-generated method stub + return false; + } } class SessionManager { private ConcurrentHashMap sessionMap = new ConcurrentHashMap(); diff --git a/bundles/org.simantics.db/src/org/simantics/db/Database.java b/bundles/org.simantics.db/src/org/simantics/db/Database.java index c72e72b75..35f384100 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/Database.java +++ b/bundles/org.simantics.db/src/org/simantics/db/Database.java @@ -135,6 +135,7 @@ public interface Database { public T clone(ClusterUID clusterUID, ClusterCreator clusterCreator) throws DatabaseException; public boolean refreshEnabled(); + boolean rolledback(); } public Session newSession(ServiceLocator locator) throws SDBException; interface Journal { diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/ClusterSetsSupport.java b/bundles/org.simantics.db/src/org/simantics/db/service/ClusterSetsSupport.java index 78d47ea98..d935a2b54 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/service/ClusterSetsSupport.java +++ b/bundles/org.simantics.db/src/org/simantics/db/service/ClusterSetsSupport.java @@ -12,6 +12,7 @@ public interface ClusterSetsSupport { void put(long resourceId, long clusterId); void save() throws IOException; void clear(); - void updateReadAndWriteDirectories(Path read, Path write); + void setReadDirectory(Path read); + void updateWriteDirectory(Path write); } -- 2.47.1