jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1539404 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ oak-jcr/src/test/jav...
Date Wed, 06 Nov 2013 17:15:00 GMT
Author: mreutegg
Date: Wed Nov  6 17:15:00 2013
New Revision: 1539404

URL: http://svn.apache.org/r1539404
Log:
OAK-1080: MongoMK: improved concurrency
- feed commit info into MongoNodeStore
- add repository stub for MongoNodeStore

Added:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoMKRepositoryStub.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1539404&r1=1539403&r2=1539404&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Wed Nov  6 17:15:00 2013
@@ -89,12 +89,15 @@ public class KernelNodeStoreBranch exten
     }
 
     @Override
-    protected KernelNodeState merge(KernelNodeState branchHead) {
+    protected KernelNodeState merge(KernelNodeState branchHead,
+                                    CommitInfo info) {
         return store.merge(branchHead);
     }
 
     @Override
-    protected KernelNodeState persist(NodeState toPersist, KernelNodeState base) {
+    protected KernelNodeState persist(NodeState toPersist,
+                                      KernelNodeState base,
+                                      CommitInfo info) {
         JsopDiff diff = new JsopDiff(blobs);
         toPersist.compareAgainstBaseState(base, diff);
         return store.commit(diff.toString(), base);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1539404&r1=1539403&r2=1539404&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Wed Nov  6 17:15:00 2013
@@ -405,7 +405,7 @@ public class MongoMK implements MicroKer
             if (!success) {
                 nodeStore.canceled(commit);
             } else {
-                nodeStore.done(commit, isBranch);
+                nodeStore.done(commit, isBranch, null);
             }
         }
         return rev.toString();
@@ -428,7 +428,7 @@ public class MongoMK implements MicroKer
         if (!revision.isBranch()) {
             throw new MicroKernelException("Not a branch: " + branchRevisionId);
         }
-        return nodeStore.merge(revision).toString();
+        return nodeStore.merge(revision, null).toString();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java?rev=1539404&r1=1539403&r2=1539404&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
Wed Nov  6 17:15:00 2013
@@ -351,8 +351,8 @@ public final class MongoNodeStore
 
     /**
      * Creates a new commit. The caller must acknowledge the commit either with
-     * {@link #done(Commit, boolean)} or {@link #canceled(Commit)}, depending
-     * on the result of the commit.
+     * {@link #done(Commit, boolean, CommitInfo)} or {@link #canceled(Commit)},
+     * depending on the result of the commit.
      *
      * @param base the base revision for the commit or <code>null</code> if the
      *             commit should use the current head revision as base.
@@ -377,9 +377,9 @@ public final class MongoNodeStore
         return c;
     }
 
-    void done(@Nonnull Commit c, boolean isBranch) {
+    void done(@Nonnull Commit c, boolean isBranch, @Nullable CommitInfo info) {
         try {
-            commitQueue.done(c, isBranch, null);
+            commitQueue.done(c, isBranch, info);
         } finally {
             backgroundOperationLock.readLock().unlock();
         }
@@ -759,7 +759,7 @@ public final class MongoNodeStore
     }
 
     @Nonnull
-    Revision merge(@Nonnull Revision branchHead) {
+    Revision merge(@Nonnull Revision branchHead, @Nullable CommitInfo info) {
         Branch b = getBranches().getBranch(branchHead);
         Revision base = branchHead;
         if (b != null) {
@@ -794,7 +794,7 @@ public final class MongoNodeStore
             if (!success) {
                 canceled(commit);
             } else {
-                done(commit, false);
+                done(commit, false, info);
             }
         }
         return commit.getRevision();

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=1539404&r1=1539403&r2=1539404&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 17:15:00 2013
@@ -81,19 +81,20 @@ public class MongoNodeStoreBranch
     }
 
     @Override
-    protected MongoNodeState merge(MongoNodeState branchHead) {
-        return store.getRoot(store.merge(branchHead.getRevision()));
+    protected MongoNodeState merge(MongoNodeState branchHead, CommitInfo info) {
+        return store.getRoot(store.merge(branchHead.getRevision(), info));
     }
 
     @Override
     protected MongoNodeState persist(final NodeState toPersist,
-                                     final MongoNodeState base) {
+                                     final MongoNodeState base,
+                                     final CommitInfo info) {
         MongoNodeState state = persist(new Changes() {
             @Override
             public void with(Commit c) {
                 toPersist.compareAgainstBaseState(base, new CommitDiff(c, blobs));
             }
-        }, base);
+        }, base, info);
         if (base.isBranch()) {
             state.setBranch();
         }
@@ -109,7 +110,7 @@ public class MongoNodeStoreBranch
             public void with(Commit c) {
                 store.copyNode(source, target, c);
             }
-        }, base);
+        }, base, null);
     }
 
     @Override
@@ -121,7 +122,7 @@ public class MongoNodeStoreBranch
             public void with(Commit c) {
                 store.moveNode(source, target, c);
             }
-        }, base);
+        }, base, null);
     }
 
     //--------------------< AbstractNodeStoreBranch >---------------------------
@@ -150,9 +151,12 @@ public class MongoNodeStoreBranch
      *
      * @param op the changes to persist.
      * @param base the base state.
+     * @param info the commit info.
      * @return the result state.
      */
-    private MongoNodeState persist(Changes op, MongoNodeState base) {
+    private MongoNodeState persist(Changes op,
+                                   MongoNodeState base,
+                                   CommitInfo info) {
         boolean success = false;
         Commit c = store.newCommit(base.getRevision());
         Revision rev;
@@ -162,7 +166,7 @@ public class MongoNodeStoreBranch
             success = true;
         } finally {
             if (success) {
-                store.done(c, base.getRevision().isBranch());
+                store.done(c, base.getRevision().isBranch(), info);
             } else {
                 store.canceled(c);
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java?rev=1539404&r1=1539403&r2=1539404&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
Wed Nov  6 17:15:00 2013
@@ -88,9 +88,10 @@ public abstract class AbstractNodeStoreB
      * Merges the branch head and returns the result state of the merge.
      *
      * @param branchHead the head of the branch to merge.
+     * @param info the commit info or <code>null</code> if none available.
      * @return the result state of the merge.
      */
-    protected abstract N merge(N branchHead);
+    protected abstract N merge(N branchHead, CommitInfo info);
 
     /**
      * Persists the changes between <code>toPersist</code> and <code>base</code>
@@ -102,9 +103,10 @@ public abstract class AbstractNodeStoreB
      *
      * @param toPersist the state with the changes on top of <code>base</code>.
      * @param base the base state.
+     * @param info the commit info or <code>null</code> if there is none.
      * @return the state with the persisted changes.
      */
-    protected abstract N persist(NodeState toPersist, N base);
+    protected abstract N persist(NodeState toPersist, N base, CommitInfo info);
 
     /**
      * Perform a potentially optimized copy operation directly on the underlying
@@ -389,7 +391,7 @@ public abstract class AbstractNodeStoreB
                 rebase();
                 dispatcher.beforeCommit(base);
                 NodeState toCommit = checkNotNull(hook).processCommit(base, head);
-                NodeState newHead = AbstractNodeStoreBranch.this.persist(toCommit, base);
+                NodeState newHead = AbstractNodeStoreBranch.this.persist(toCommit, base,
info);
                 dispatcher.localCommit(newHead, info);
                 branchState = new Merged(base);
                 return newHead;
@@ -473,8 +475,8 @@ public abstract class AbstractNodeStoreB
                     branchState = new Merged(base);
                     return base;
                 } else {
-                    head = AbstractNodeStoreBranch.this.persist(toCommit, head);
-                    NodeState newRoot = AbstractNodeStoreBranch.this.merge(head);
+                    head = AbstractNodeStoreBranch.this.persist(toCommit, head, info);
+                    NodeState newRoot = AbstractNodeStoreBranch.this.merge(head, info);
                     dispatcher.localCommit(newRoot, info);
                     branchState = new Merged(base);
                     return newRoot;
@@ -486,7 +488,7 @@ public abstract class AbstractNodeStoreB
 
         private void persistTransientHead(NodeState newHead) {
             if (!newHead.equals(head)) {
-                head = AbstractNodeStoreBranch.this.persist(newHead, head);
+                head = AbstractNodeStoreBranch.this.persist(newHead, head, null);
             }
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoMKRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoMKRepositoryStub.java?rev=1539404&r1=1539403&r2=1539404&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoMKRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoMKRepositoryStub.java
Wed Nov  6 17:15:00 2013
@@ -70,11 +70,7 @@ public class OakMongoMKRepositoryStub ex
         Session session = null;
         try {
             this.connection = new MongoConnection(HOST, PORT, DB);
-            MongoMK m = new MongoMK.Builder().setClusterId(1).
-                    memoryCacheSize(64 * 1024 * 1024).
-                    setMongoDB(connection.getDB()).open();
-            Jcr jcr = new Jcr(m);
-            this.repository = jcr.createRepository();
+            this.repository = createRepository(connection);
 
             session = getRepository().login(superuser);
             TestContentLoader loader = new TestContentLoader();
@@ -90,6 +86,14 @@ public class OakMongoMKRepositoryStub ex
                 new Thread(new ShutdownHook(connection)));
     }
 
+    protected Repository createRepository(MongoConnection connection) {
+        MongoMK m = new MongoMK.Builder().setClusterId(1).
+                memoryCacheSize(64 * 1024 * 1024).
+                setMongoDB(connection.getDB()).open();
+        Jcr jcr = new Jcr(m);
+        return jcr.createRepository();
+    }
+
     /**
      * A shutdown hook that closed the MongoDB connection if needed.
      */

Added: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java?rev=1539404&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
Wed Nov  6 17:15:00 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr;
+
+import java.util.Properties;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.plugins.mongomk.MongoMK;
+import org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore;
+import org.apache.jackrabbit.oak.plugins.mongomk.util.MongoConnection;
+
+/**
+ * A repository stub using the MongoNodeStore.
+ */
+public class OakMongoNSRepositoryStub extends OakMongoMKRepositoryStub {
+
+    public OakMongoNSRepositoryStub(Properties settings)
+            throws RepositoryException {
+        super(settings);
+    }
+
+    @Override
+    protected Repository createRepository(MongoConnection connection) {
+        MongoNodeStore store = new MongoMK.Builder().setClusterId(1).
+                memoryCacheSize(64 * 1024 * 1024).
+                setMongoDB(connection.getDB()).getNodeStore();
+        return new Jcr(store).createRepository();
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakMongoNSRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message