jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1450265 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype: MongoDocumentStore.java Node.java
Date Tue, 26 Feb 2013 16:35:56 GMT
Author: thomasm
Date: Tue Feb 26 16:35:55 2013
New Revision: 1450265

URL: http://svn.apache.org/r1450265
Log:
OAK-619 Lock-free MongoMK implementation (fix simple bugs)

Modified:
    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/Node.java

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=1450265&r1=1450264&r2=1450265&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 26 16:35:55 2013
@@ -31,6 +31,7 @@ import com.mongodb.DB;
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
+import com.mongodb.MongoException;
 import com.mongodb.QueryBuilder;
 import com.mongodb.WriteConcern;
 import com.mongodb.WriteResult;
@@ -165,7 +166,7 @@ public class MongoDocumentStore implemen
                     break;
                 }
                 case ADD_MAP_ENTRY: {
-                    setUpdates.append(k, op.value.toString());
+                    setUpdates.append(k, op.value);
                     break;
                 }
                 case REMOVE_MAP_ENTRY: {
@@ -175,7 +176,7 @@ public class MongoDocumentStore implemen
                 case SET_MAP_ENTRY: {
                     String[] kv = k.split("\\.");
                     BasicDBObject sub = new BasicDBObject();
-                    sub.put(kv[1], op.value.toString());
+                    sub.put(kv[1], op.value);
                     setUpdates.append(kv[0], sub);
                     break;
                 }
@@ -255,17 +256,21 @@ public class MongoDocumentStore implemen
         DBCollection dbCollection = getDBCollection(collection);
         long start = start();
         try {
-            WriteResult writeResult = dbCollection.insert(inserts, WriteConcern.SAFE);
-            if (writeResult.getError() != null) {
-                throw new MicroKernelException("Batch create failed: " + writeResult.getError());
-            }
-            synchronized (cache) {
-                for (Map<String, Object> map : maps) {
-                    String path = (String) map.get(UpdateOp.ID);
-                    synchronized (cache) {
-                        cache.put(path, map);
+            try {
+                WriteResult writeResult = dbCollection.insert(inserts, WriteConcern.SAFE);
+                if (writeResult.getError() != null) {
+                    throw new MicroKernelException("Batch create failed: " + writeResult.getError());
+                }
+                synchronized (cache) {
+                    for (Map<String, Object> map : maps) {
+                        String path = (String) map.get(UpdateOp.ID);
+                        synchronized (cache) {
+                            cache.put(path, map);
+                        }
                     }
                 }
+            } catch (MongoException e) {
+                throw new MicroKernelException("Batch create failed", e);
             }
         } finally {
             end(start);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Node.java?rev=1450265&r1=1450264&r2=1450265&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Node.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Node.java
Tue Feb 26 16:35:55 2013
@@ -37,7 +37,11 @@ public class Node {
     }
     
     void setProperty(String propertyName, String value) {
-        properties.put(propertyName, value);
+        if (value == null) {
+            properties.remove(propertyName);
+        } else {
+            properties.put(propertyName, value);
+        }
     }
     
     public String getProperty(String propertyName) {



Mime
View raw message