]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Re-enabled Acorn transaction cancellation support for testing 17/217/2
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 20 Dec 2016 05:07:06 +0000 (07:07 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 23 Dec 2016 07:36:03 +0000 (09:36 +0200)
refs #6887

Change-Id: I844171225284cb7a9d28b6ab5f00c4db88e2afa0

bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java
bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ChangeSetInfo.java

index 51db52efc55a43108df3939b5bd23561700b6784..b2a30953cca9e0bff26e72dc69a788139e52a817 100644 (file)
@@ -70,7 +70,7 @@ public class ClusterManager {
                info.acquireMutex();
                try {
                        info.makeResident();
-                       return info.getCSSIds();
+                       return info.getCCSIds();
                } finally {
                        info.releaseMutex();
                }
index 05f9c8de00b66c315f9a6c5317026f28c0c664cb..90af336aafdc079fe99b6210ad9d139211d86f45 100644 (file)
@@ -122,10 +122,10 @@ public class GraphClientImpl2 implements Database.Session {
                                                mainProgram.mutex.release();
                                        }
                                } catch (IllegalAcornStateException | ProCoreException e) {
-                                       Logger.defaultLogError(e);
+                                       Logger.defaultLogError("Snapshotting failed", e);
                                        unexpectedClose = true;
                                } catch (InterruptedException e) {
-                                       Logger.defaultLogError(e);
+                                       Logger.defaultLogError("Snapshotting interrupted", e);
                                } finally {
                                        try {
                                                if(tr != null)
@@ -135,11 +135,11 @@ public class GraphClientImpl2 implements Database.Session {
                            try {
                                support.close();
                            } catch (DatabaseException e1) {
-                               Logger.defaultLogError(e1);
+                               Logger.defaultLogError("Failed to close database as a safety measure due to failed snapshotting", e1);
                            }
                                                }
                                        } catch (ProCoreException e) {
-                                               Logger.defaultLogError(e);
+                                               Logger.defaultLogError("Failed to end snapshotting write transaction", e);
                                        }
                                }
                        }
@@ -239,18 +239,17 @@ public class GraphClientImpl2 implements Database.Session {
 
        @Override
        public long cancelCommit(long transactionId, long changeSetId, byte[] metadata, OnChangeSetUpdate onChangeSetUpdate) throws ProCoreException {
-           UnsupportedOperationException e = new UnsupportedOperationException("org.simantics.acorn.GraphClientImpl2.cancelCommit() is not supported operation! Closing down to prevent further havoc");
-           clusters.notSafeToMakeSnapshot(new IllegalAcornStateException(e));
-           throw e;
-//         System.err.println("GraphClientImpl2.cancelCommit() called!! this is experimental and might cause havoc!");
-//         try {
-//            undo(new long[] {changeSetId}, onChangeSetUpdate);
-//        } catch (SDBException e) {
-//            e.printStackTrace();
-//            throw new ProCoreException(e);
-//        }
-//         clusters.state.headChangeSetId++;
-//         return clusters.state.headChangeSetId;
+               // Accept and finalize current transaction and then undo it
+               acceptCommit(transactionId, changeSetId, metadata);
+
+               try {
+                       undo(new long[] {changeSetId+1}, onChangeSetUpdate);
+                       clusters.state.headChangeSetId++;
+                       return clusters.state.headChangeSetId;
+               } catch (SDBException e) {
+                       Logger.defaultLogError("Failed to undo cancelled transaction", e);
+                       throw new ProCoreException(e);
+               }
        }
 
        @Override
@@ -622,10 +621,11 @@ public class GraphClientImpl2 implements Database.Session {
                        ArrayList<String> ccss = clusters.getChanges(id);
     
                        for(int j=0;j<ccss.size();j++) {
+                               String ccsid = ccss.get(ccss.size()-j-1);
                                try {
                                        if(ClusterUpdateProcessorBase.DEBUG)
-                                               System.err.println("performUndo " + ccss.get(ccss.size()-j-1));
-                                       performUndo(ccss.get(ccss.size()-j-1), clusterChanges, support);
+                                               System.err.println("performUndo " + ccsid);
+                                       performUndo(ccsid, clusterChanges, support);
                                } catch (DatabaseException e) {
                                        e.printStackTrace();
                                }
index a730e136d3b8bce4c6bd18b922fb3344a0285d53..a19a8540b48d3faafcf002541a622032046396a8 100644 (file)
@@ -31,7 +31,7 @@ public class ChangeSetInfo extends LRUObject<Long, ChangeSetInfo> {
                LRU.insert(this, accessTime);
        }
        
-       public ArrayList<String> getCSSIds() throws AcornAccessVerificationException {
+       public ArrayList<String> getCCSIds() throws AcornAccessVerificationException {
                if(VERIFY) verifyAccess();
                return clusterChangeSetIds;
        }