jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1447717 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype: Commit.java MongoDocumentStore.java MongoMK.java
Date Tue, 19 Feb 2013 13:39:42 GMT
Author: thomasm
Date: Tue Feb 19 13:39:41 2013
New Revision: 1447717

URL: http://svn.apache.org/r1447717
Log:
OAK-619 Lock-free MongoMK implementation (WIP)

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/MongoDocumentStore.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=1447717&r1=1447716&r2=1447717&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
Tue Feb 19 13:39:41 2013
@@ -76,6 +76,7 @@ public class Commit {
         ArrayList<UpdateOp> newNodes = new ArrayList<UpdateOp>();
         ArrayList<UpdateOp> changedNodes = new ArrayList<UpdateOp>();
         for (String p : operations.keySet()) {
+            addChangedParent(p);
             if (commitRoot == null) {
                 commitRoot = p;
             } else {
@@ -87,7 +88,6 @@ public class Commit {
                 }
             }
         }
-        addChangedParent(commitRoot);
         // create a "root of the commit" if there is none
         UpdateOp root = getUpdateOperationForNode(commitRoot);
         for (String p : operations.keySet()) {
@@ -100,16 +100,19 @@ public class Commit {
                 changedNodes.add(op);
             }
         }
-        if (changedNodes.size() == 0) {
+        if (changedNodes.size() == 0 && root.isNew) {
             // no updates, so we just add the root like the others
             newNodes.add(root);
             root = null;
         }
-        store.create(Collection.NODES, newNodes);
+        if (newNodes.size() > 0) {
+            store.create(Collection.NODES, newNodes);
+        }
         for (UpdateOp op : changedNodes) {
             store.createOrUpdate(Collection.NODES, op);
         }
         if (root != null) {
+            root.addMapEntry("_revisions", revision.toString(), "true");
             store.createOrUpdate(Collection.NODES, root);
         }
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStore.java?rev=1447717&r1=1447716&r2=1447717&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStore.java
Tue Feb 19 13:39:41 2013
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mongomk.prototype.UpdateOp.Operation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -127,10 +128,14 @@ public class MongoDocumentStore implemen
 //                WriteConcern.SAFE);
 //        return null;
 
-        DBObject oldNode = dbCollection.findAndModify(query, null /*fields*/,
-                null /*sort*/, false /*remove*/, update, false /*returnNew*/,
-                true /*upsert*/);
-        return convertFromDBObject(oldNode);
+        try {
+            DBObject oldNode = dbCollection.findAndModify(query, null /*fields*/,
+                    null /*sort*/, false /*remove*/, update, false /*returnNew*/,
+                    true /*upsert*/);
+            return convertFromDBObject(oldNode);
+        } catch (Exception e) {
+            throw new MicroKernelException(e);
+        }
     }
 
     @Override

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=1447717&r1=1447716&r2=1447717&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
Tue Feb 19 13:39:41 2013
@@ -346,9 +346,9 @@ public class MongoMK implements MicroKer
         json.key(":childNodeCount").value(c.children.size());
         json.endObject();
         String result = json.toString();
-        if (filter != null && filter.contains(":hash")) {
-            result = result.replaceAll("\":id\"", "\":hash\"");
-        }
+        // if (filter != null && filter.contains(":hash")) {
+        //     result = result.replaceAll("\":id\"", "\":hash\"");
+        // }
         return result;
     }
 



Mime
View raw message