Author: chetanm
Date: Wed Oct 19 15:11:41 2016
New Revision: 1765645

URL: http://svn.apache.org/viewvc?rev=1765645&view=rev
Log:
OAK-1312 -  [bundling] Bundle nodes into a document

Ensure that bundled nodes are not made part of unsaved modifications and hence 
not part of background writes

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1765645&r1=1765644&r2=1765645&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
 Wed Oct 19 15:11:41 2016
@@ -32,10 +32,9 @@ import javax.annotation.Nullable;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
-
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -384,7 +383,7 @@ public class Commit {
             }
 
             //Ignore setting children path for bundled nodes
-            if (bundledNodes.contains(parentPath)){
+            if (isBundled(parentPath)){
                 continue;
             }
 
@@ -664,7 +663,9 @@ public class Commit {
             boolean isNew = op != null && op.isNew();
             if (op == null || !hasContentChanges(op) || denotesRoot(path)) {
                 // track intermediate node and root
-                tracker.track(path);
+                if (!isBundled(path)) {
+                    tracker.track(path);
+                }
             }
             nodeStore.applyChanges(before, after, rev, path, isNew,
                     added, removed, changed, cacheEntry);
@@ -697,6 +698,10 @@ public class Commit {
         }
     }
 
+    private boolean isBundled(String parentPath) {
+        return bundledNodes.contains(parentPath);
+    }
+
     private static final Function<UpdateOp.Key, String> KEY_TO_NAME =
             new Function<UpdateOp.Key, String>() {
         @Override

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java?rev=1765645&r1=1765644&r2=1765645&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
 Wed Oct 19 15:11:41 2016
@@ -452,6 +452,23 @@ public class DocumentBundlingTest {
         AssertingDiff.assertEquals(appNode, appNode2);
     }
 
+    @Test
+    public void bundledDocsShouldNotBePartOfBackgroundUpdate() throws 
Exception{
+        NodeBuilder builder = store.getRoot().builder();
+        NodeBuilder fileNode = newNode("nt:file");
+        fileNode.child("jcr:content").setProperty("jcr:data", "foo");
+        builder.child("test").setChildNode("book.jpg", 
fileNode.getNodeState());
+
+        merge(builder);
+        builder = store.getRoot().builder();
+        childBuilder(builder, 
"/test/book.jpg/jcr:content/vlt:definition").setProperty("foo", "bar");
+        merge(builder);
+
+        //2 for /test, /test/book.jpg and /test/book.jpg/jcr:content should be 
there
+        //TODO If UnsavedModification is made public we can assert on path 
itself
+        assertEquals(2, store.getPendingWriteCount());
+    }
+
     private void createTestNode(String path, NodeState state) throws 
CommitFailedException {
         String parentPath = PathUtils.getParentPath(path);
         NodeBuilder builder = store.getRoot().builder();


Reply via email to