jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1515408 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/ oak-core/src/test/java/org/apache/jackrabbit/oak/core/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/
Date Mon, 19 Aug 2013 13:31:58 GMT
Author: mreutegg
Date: Mon Aug 19 13:31:58 2013
New Revision: 1515408

URL: http://svn.apache.org/r1515408
Log:
OAK-962: RootFuzzIT fails on MongoMK with seed -1091889749
- Use base revision of commit in MongoMK.markAsDeleted()
- Enable test in RootTest and RepositoryTest (RootFuzzIT still fails)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java?rev=1515408&r1=1515407&r2=1515408&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
Mon Aug 19 13:31:58 2013
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -94,9 +95,29 @@ public class Commit {
         return timestamp / 1000 / 5;
     }
 
-    public Revision getRevision() {
+    /**
+     * The revision for this new commit. That is, the changes within this commit
+     * will be visible with this revision.
+     *
+     * @return the revision for this new commit.
+     */
+    @Nonnull
+    Revision getRevision() {
         return revision;
     }
+
+    /**
+     * Returns the base revision for this commit. That is, the revision passed
+     * to {@link MongoMK#commit(String, String, String, String)}. The base
+     * revision may be <code>null</code>, e.g. for the initial commit of the
+     * root node, when there is no base revision.
+     *
+     * @return the base revision of this commit or <code>null</code>.
+     */
+    @CheckForNull
+    Revision getBaseRevision() {
+        return baseRevision;
+    }
     
     void addNodeDiff(Node n) {
         diff.tag('+').key(n.path);

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=1515408&r1=1515407&r2=1515408&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
Mon Aug 19 13:31:58 2013
@@ -63,6 +63,9 @@ import com.google.common.cache.CacheBuil
 import com.google.common.cache.Weigher;
 import com.mongodb.DB;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
 /**
  * A MicroKernel implementation that stores the data in a MongoDB.
  */
@@ -440,8 +443,8 @@ public class MongoMK implements MicroKer
      * @param rev
      * @return the node
      */
-    Node getNode(String path, Revision rev) {
-        checkRevisionAge(rev, path);
+    Node getNode(@Nonnull String path, @Nonnull Revision rev) {
+        checkRevisionAge(checkNotNull(rev), checkNotNull(path));
         String key = path + "@" + rev;
         Node node = nodeCache.getIfPresent(key);
         if (node == null) {
@@ -848,7 +851,7 @@ public class MongoMK implements MicroKer
                     throw new MicroKernelException("Node already exists: " + targetPath +
" in revision " + baseRevId);
                 }
                 commit.moveNode(sourcePath, targetPath);
-                moveNode(sourcePath, targetPath, baseRev, commit);
+                moveNode(sourcePath, targetPath, commit);
                 break;
             }
             case '*': {
@@ -865,7 +868,7 @@ public class MongoMK implements MicroKer
                     throw new MicroKernelException("Node already exists: " + targetPath +
" in revision " + baseRevId);
                 }
                 commit.copyNode(sourcePath, targetPath);
-                copyNode(sourcePath, targetPath, baseRev, commit);
+                copyNode(sourcePath, targetPath, commit);
                 break;
             }
             default:
@@ -953,18 +956,17 @@ public class MongoMK implements MicroKer
         return clusterId;
     }
 
-    private void copyNode(String sourcePath, String targetPath, Revision baseRev, Commit
commit) {
-        moveOrCopyNode(false, sourcePath, targetPath, baseRev, commit);
+    private void copyNode(String sourcePath, String targetPath, Commit commit) {
+        moveOrCopyNode(false, sourcePath, targetPath, commit);
     }
     
-    private void moveNode(String sourcePath, String targetPath, Revision baseRev, Commit
commit) {
-        moveOrCopyNode(true, sourcePath, targetPath, baseRev, commit);
+    private void moveNode(String sourcePath, String targetPath, Commit commit) {
+        moveOrCopyNode(true, sourcePath, targetPath, commit);
     }
     
     private void moveOrCopyNode(boolean move,
                                 String sourcePath,
                                 String targetPath,
-                                Revision baseRev,
                                 Commit commit) {
         // TODO Optimize - Move logic would not work well with very move of very large subtrees
         // At minimum we can optimize by traversing breadth wise and collect node id
@@ -974,7 +976,7 @@ public class MongoMK implements MicroKer
         // of this commit i.e. transient nodes. If its required it would need to be looked
         // into
 
-        Node n = getNode(sourcePath, baseRev);
+        Node n = getNode(sourcePath, commit.getBaseRevision());
 
         // Node might be deleted already
         if (n == null) {
@@ -988,16 +990,17 @@ public class MongoMK implements MicroKer
         if (move) {
             markAsDeleted(sourcePath, commit, false);
         }
-        Node.Children c = getChildren(sourcePath, baseRev, Integer.MAX_VALUE);
+        Node.Children c = getChildren(sourcePath, commit.getBaseRevision(), Integer.MAX_VALUE);
         for (String srcChildPath : c.children) {
             String childName = PathUtils.getName(srcChildPath);
             String destChildPath = PathUtils.concat(targetPath, childName);
-            moveOrCopyNode(move, srcChildPath, destChildPath, baseRev, commit);
+            moveOrCopyNode(move, srcChildPath, destChildPath, commit);
         }
     }
 
     private void markAsDeleted(String path, Commit commit, boolean subTreeAlso) {
-        Revision rev = commit.getRevision();
+        Revision rev = commit.getBaseRevision();
+        checkState(rev != null, "Base revision of commit must not be null");
         commit.removeNode(path);
 
         if (subTreeAlso) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java?rev=1515408&r1=1515407&r2=1515408&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java
Mon Aug 19 13:31:58 2013
@@ -478,9 +478,6 @@ public class RootTest extends OakBaseTes
 
     @Test
     public void oak962() throws CommitFailedException {
-        // FIXME Fails on MongoMK. See OAK-962
-        assumeTrue(fixture != NodeStoreFixture.MONGO_MK);
-
         Root root = session.getLatestRoot();
         Tree r = root.getTree("/").addChild("root");
         r.addChild("N3");

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1515408&r1=1515407&r2=1515408&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Mon Aug 19 13:31:58 2013
@@ -1595,7 +1595,6 @@ public class RepositoryTest extends Abst
     }
 
     @Test
-    @Ignore("OAK-962")  // FIXME OAK-962
     public void oak962() throws RepositoryException {
         Session session = getAdminSession();
         Node root = session.getRootNode().addNode("root");



Mime
View raw message