jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1466392 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype: Commit.java MongoMK.java
Date Wed, 10 Apr 2013 09:00:16 GMT
Author: mreutegg
Date: Wed Apr 10 09:00:16 2013
New Revision: 1466392

URL: http://svn.apache.org/r1466392
Log:
OAK-619 Lock-free MongoMK implementation
- Add check for updates of unsavedLastRevisions map
- Do not use regular commit mechanism for update of _lastRev

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java?rev=1466392&r1=1466391&r2=1466392&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
Wed Apr 10 09:00:16 2013
@@ -68,7 +68,7 @@ public class Commit {
         this.mk = mk;
     }
 
-    private UpdateOp getUpdateOperationForNode(String path) {
+    UpdateOp getUpdateOperationForNode(String path) {
         UpdateOp op = operations.get(path);
         if (op == null) {
             String id = Utils.getIdFromPath(path);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java?rev=1466392&r1=1466391&r2=1466392&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
Wed Apr 10 09:00:16 2013
@@ -323,7 +323,7 @@ public class MongoMK implements MicroKer
                 }
                 return o1.compareTo(o2);
             }
-            
+
         });
         long now = Revision.getCurrentTimestamp();
         for (String p : paths) {
@@ -332,16 +332,16 @@ public class MongoMK implements MicroKer
                 continue;
             }
             // FIXME: with below code fragment the root (and other nodes
-            // 'close' to the root will not be updated in MongoDB when there
-            // are frequent changes. Uncommenting the lines below also
-            // leads to test failures because reads seem to become inconsistent
-//            if (Revision.getTimestampDifference(now, r.getTimestamp()) < asyncDelay)
{
-//                continue;
-//            }
+            // 'close' to the root) will not be updated in MongoDB when there
+            // are frequent changes.
+            if (Revision.getTimestampDifference(now, r.getTimestamp()) < asyncDelay) {
+                continue;
+            }
             
             Commit commit = new Commit(this, null, r);
             commit.touchNode(p);
-            commit.apply();
+            store.createOrUpdate(DocumentStore.Collection.NODES, commit.getUpdateOperationForNode(p));
+            unsavedLastRevisions.remove(p);
         }
     }
     
@@ -1203,7 +1203,18 @@ public class MongoMK implements MicroKer
             boolean isNew, boolean isDelete, boolean isWritten, 
             ArrayList<String> added, ArrayList<String> removed) {
         if (!isWritten) {
-            unsavedLastRevisions.put(path, rev);
+            Revision prev = unsavedLastRevisions.put(path, rev);
+            if (prev != null) {
+                if (isRevisionNewer(prev, rev)) {
+                    // revert
+                    unsavedLastRevisions.put(path, prev);
+                    String msg = String.format("Attempt to update " +
+                            "unsavedLastRevision for %s with %s, which is " +
+                            "older than current %s.",
+                            path, rev, prev);
+                    throw new MicroKernelException(msg);
+                }
+            }
         } else {
             // the document was updated:
             // we no longer need to update it in a background process



Mime
View raw message