jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1445180 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
Date Tue, 12 Feb 2013 14:23:42 GMT
Author: jukka
Date: Tue Feb 12 14:23:41 2013
New Revision: 1445180

URL: http://svn.apache.org/r1445180
Log:
OAK-593: Segment-based MK

MongoStore initialization and proper atomic journal updates

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java?rev=1445180&r1=1445179&r2=1445180&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
Tue Feb 12 14:23:41 2013
@@ -20,6 +20,8 @@ import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
+
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -56,6 +58,15 @@ public class MongoStore implements Segme
                         return findSegment(key);
                     }
                 });
+
+        SegmentWriter writer = new SegmentWriter(this);
+        RecordId id = writer.writeNode(MemoryNodeState.EMPTY_NODE);
+        writer.flush();
+        journals.update(
+                new BasicDBObject("_id", "root"),
+                new BasicDBObject(ImmutableMap.of(
+                        "_id", "root", "head", id.toString())),
+                true /* upsert */, false);
     }
 
     public MongoStore(DB db) {
@@ -79,7 +90,7 @@ public class MongoStore implements Segme
                 ImmutableMap.of("_id", "root", "head", base.toString()));
         DBObject headObject = new BasicDBObject(
                 ImmutableMap.of("_id", "root", "head", head.toString()));
-        return journals.update(baseObject, headObject).getN() == 1;
+        return journals.findAndModify(baseObject, headObject) != null;
     }
 
     @Override



Mime
View raw message