jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1539251 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/
Date Wed, 06 Nov 2013 07:41:21 GMT
Author: mreutegg
Date: Wed Nov  6 07:41:20 2013
New Revision: 1539251

URL: http://svn.apache.org/r1539251
Log:
OAK-1080: MongoMK: improved concurrency
- add MongoNodeStore fixture in oak-jcr
- retries on merge failures

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeState.java?rev=1539251&r1=1539250&r2=1539251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeState.java
Wed Nov  6 07:41:20 2013
@@ -35,6 +35,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.LongPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
+import org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
 import org.apache.jackrabbit.oak.plugins.value.Conversions;
@@ -101,10 +102,13 @@ final class MongoNodeState extends Abstr
             return true;
         } else if (that instanceof MongoNodeState) {
             MongoNodeState other = (MongoNodeState) that;
-            if (node.getLastRevision().equals(other.node.getLastRevision()) && getPath().equals(other.getPath()))
{
-                return true;
-            } else {
-                // TODO: optimize equals check for this case
+            if (getPath().equals(other.getPath())) {
+                return node.getLastRevision().equals(other.node.getLastRevision());
+            }
+        } else if (that instanceof ModifiedNodeState) {
+            ModifiedNodeState modified = (ModifiedNodeState) that;
+            if (modified.getBaseState() == this) {
+                return false;
             }
         }
         if (that instanceof NodeState) {
@@ -156,7 +160,11 @@ final class MongoNodeState extends Abstr
     public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
         // TODO: handle many child nodes better
         Node.Children children = store.getChildren(getPath(),
-                node.getLastRevision(), Integer.MAX_VALUE);
+                node.getLastRevision(), 100);
+        if (children.hasMore) {
+            children = store.getChildren(getPath(),
+                    node.getLastRevision(), Integer.MAX_VALUE);
+        }
         return Iterables.transform(children.children, new Function<String, ChildNodeEntry>()
{
             @Override
             public ChildNodeEntry apply(String path) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java?rev=1539251&r1=1539250&r2=1539251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
Wed Nov  6 07:41:20 2013
@@ -18,9 +18,16 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.io.IOException;
 
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.kernel.BlobSerializer;
 import org.apache.jackrabbit.oak.plugins.observation.ChangeDispatcher;
+import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStoreBranch;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -30,6 +37,12 @@ import org.apache.jackrabbit.oak.spi.sta
 public class MongoNodeStoreBranch
         extends AbstractNodeStoreBranch<MongoNodeStore, MongoNodeState> {
 
+    /**
+     * TODO: what is a reasonable value?
+     * TODO: fall back to pessimistic approach? how does this work in a cluster?
+     */
+    private static final int MERGE_RETRIES = 10;
+
     private final BlobSerializer blobs = new BlobSerializer() {
         @Override
         public String serialize(Blob blob) {
@@ -111,6 +124,25 @@ public class MongoNodeStoreBranch
         }, base);
     }
 
+    //--------------------< AbstractNodeStoreBranch >---------------------------
+
+    @Nonnull
+    @Override
+    public NodeState merge(@Nonnull CommitHook hook, @Nullable CommitInfo info)
+            throws CommitFailedException {
+        MicroKernelException ex = null;
+        for (int i = 0; i < MERGE_RETRIES; i++) {
+            try {
+                return super.merge(hook, info);
+            } catch (MicroKernelException e) {
+                ex = e;
+            }
+        }
+        throw new CommitFailedException(
+                "Kernel", 1,
+                "Failed to merge changes to the underlying store", ex);
+    }
+
     //------------------------------< internal >--------------------------------
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java?rev=1539251&r1=1539250&r2=1539251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
Wed Nov  6 07:41:20 2013
@@ -49,6 +49,7 @@ public abstract class AbstractRepository
         Object[][] fixtures = new Object[][] {
                 {NodeStoreFixture.MK_IMPL},
                 {NodeStoreFixture.MONGO_MK},
+                {NodeStoreFixture.MONGO_NS},
                 {NodeStoreFixture.SEGMENT_MK},
         };
         return Arrays.asList(fixtures);



Mime
View raw message