]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionSocket.java
Cluster loading problem fix made by Antti
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / GraphSessionSocket.java
index ed6a5ba0437230a772222c88bc04b4edbba45b8f..9a94d83452f6bf75633e022cfcc5d62ec2e55559 100644 (file)
@@ -1,91 +1,91 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package fi.vtt.simantics.procore.internal;\r
-\r
-import org.simantics.db.SessionReference;\r
-import org.simantics.db.Database.Session;\r
-import org.simantics.db.Database.Session.Information;\r
-import org.simantics.db.Database.Session.Transaction;\r
-import org.simantics.db.common.utils.Logger;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-import fi.vtt.simantics.procore.DebugPolicy;\r
-\r
-final class GraphSessionSocket extends GraphSession {\r
-    \r
-    public GraphSessionSocket(SessionImplSocket sessionImpl, SessionReference sessionReference, Session dbSession)\r
-    throws DatabaseException {\r
-        super(sessionImpl, sessionReference, dbSession);\r
-    }\r
-    @Override\r
-    protected ServerInformationImpl getServerInformation()\r
-    throws DatabaseException {\r
-        Information t = dbSession.getInformation();\r
-        return new ServerInformationImpl(t.getServerId(), t.getProtocolId(), t.getDatabaseId(), t.getFirstChangeSetId());\r
-    }\r
-    @Override\r
-    public long askReadTransaction(int thread)\r
-    throws DatabaseException {\r
-        Transaction t = dbSession.askReadTransaction();\r
-        updateLastChangeSetId(thread, t.getHeadChangeSetId(), true);\r
-        return t.getTransactionId();\r
-    }\r
-    @Override\r
-    public long askWriteTransaction(int thread, long transactionId)\r
-    throws DatabaseException {\r
-        Transaction t = dbSession.askWriteTransaction(transactionId);\r
-        updateLastChangeSetId(thread, t.getHeadChangeSetId(), true);\r
-        return t.getTransactionId();\r
-    }\r
-    @Override\r
-    public void endTransaction(long transactionId, boolean write)\r
-    throws DatabaseException {\r
-        long headChangeSetId = dbSession.endTransaction(transactionId);\r
-        updateLastChangeSetId(Integer.MIN_VALUE, headChangeSetId, false);\r
-    }\r
-    @Override\r
-    public void cancelCommit(long transactionId, long csid, byte[] metadata, SynchronizeContextI context)\r
-    throws DatabaseException {\r
-        try {\r
-            assert(null == synchronizeContext);\r
-            synchronizeContext = context;\r
-            long headChangeSetId = dbSession.cancelCommit(transactionId, csid, metadata, context);\r
-            if (csid+1 != headChangeSetId)\r
-                Logger.defaultLogError("Client and server out of synchronisation. Client cs="\r
-                    + (csid+1) + "server cs=" + headChangeSetId);\r
-            metadataCache.addNext(headChangeSetId, metadata);\r
-        } finally {\r
-            synchronizeContext = null;\r
-        }\r
-    }\r
-    @Override\r
-    public void acceptCommit(long transactionId, long csid, byte[] metadata)\r
-    throws DatabaseException {\r
-        dbSession.acceptCommit(transactionId, csid, metadata);\r
-        metadataCache.addNext(csid+1, metadata);\r
-    }\r
-    @Override\r
-    public void stop()\r
-    throws DatabaseException {\r
-        dbSession.close();\r
-    }\r
-    @Override\r
-    public long reserveIds(int count)\r
-    throws DatabaseException {\r
-        Logger.defaultLogTrace("Asking for ids " + count + ".");\r
-        long firstId = dbSession.reserveIds(count);\r
-        Logger.defaultLogTrace("First id is " + firstId + ".");\r
-        if (DebugPolicy.REPORT_CLUSTER_ID_ALLOCATION)\r
-            System.out.println("Client reserves new ids [" + firstId + " - " + (firstId+count-1) + "] from server.");\r
-        return firstId;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package fi.vtt.simantics.procore.internal;
+
+import org.simantics.db.SessionReference;
+import org.simantics.db.Database.Session;
+import org.simantics.db.Database.Session.Information;
+import org.simantics.db.Database.Session.Transaction;
+import org.simantics.db.common.utils.Logger;
+import org.simantics.db.exception.DatabaseException;
+
+import fi.vtt.simantics.procore.DebugPolicy;
+
+final class GraphSessionSocket extends GraphSession {
+    
+    public GraphSessionSocket(SessionImplSocket sessionImpl, SessionReference sessionReference, Session dbSession)
+    throws DatabaseException {
+        super(sessionImpl, sessionReference, dbSession);
+    }
+    @Override
+    protected ServerInformationImpl getServerInformation()
+    throws DatabaseException {
+        Information t = dbSession.getInformation();
+        return new ServerInformationImpl(t.getServerId(), t.getProtocolId(), t.getDatabaseId(), t.getFirstChangeSetId());
+    }
+    @Override
+    public long askReadTransaction(int thread)
+    throws DatabaseException {
+        Transaction t = dbSession.askReadTransaction();
+        updateLastChangeSetId(thread, t.getHeadChangeSetId(), true);
+        return t.getTransactionId();
+    }
+    @Override
+    public long askWriteTransaction(int thread, long transactionId)
+    throws DatabaseException {
+        Transaction t = dbSession.askWriteTransaction(transactionId);
+        updateLastChangeSetId(thread, t.getHeadChangeSetId(), true);
+        return t.getTransactionId();
+    }
+    @Override
+    public void endTransaction(long transactionId, boolean write)
+    throws DatabaseException {
+        long headChangeSetId = dbSession.endTransaction(transactionId);
+        updateLastChangeSetId(Integer.MIN_VALUE, headChangeSetId, false);
+    }
+    @Override
+    public void cancelCommit(long transactionId, long csid, byte[] metadata, SynchronizeContextI context)
+    throws DatabaseException {
+        try {
+            assert(null == synchronizeContext);
+            synchronizeContext = context;
+            long headChangeSetId = dbSession.cancelCommit(transactionId, csid, metadata, context);
+            if (csid+1 != headChangeSetId)
+                Logger.defaultLogError("Client and server out of synchronisation. Client cs="
+                    + (csid+1) + "server cs=" + headChangeSetId);
+            metadataCache.addNext(headChangeSetId, metadata);
+        } finally {
+            synchronizeContext = null;
+        }
+    }
+    @Override
+    public void acceptCommit(long transactionId, long csid, byte[] metadata)
+    throws DatabaseException {
+        dbSession.acceptCommit(transactionId, csid, metadata);
+        metadataCache.addNext(csid+1, metadata);
+    }
+    @Override
+    public void stop()
+    throws DatabaseException {
+        dbSession.close();
+    }
+    @Override
+    public long reserveIds(int count)
+    throws DatabaseException {
+        Logger.defaultLogTrace("Asking for ids " + count + ".");
+        long firstId = dbSession.reserveIds(count);
+        Logger.defaultLogTrace("First id is " + firstId + ".");
+        if (DebugPolicy.REPORT_CLUSTER_ID_ALLOCATION)
+            System.out.println("Client reserves new ids [" + firstId + " - " + (firstId+count-1) + "] from server.");
+        return firstId;
+    }
+}