Author: chetanm
Date: Mon Nov 7 15:40:49 2016
New Revision: 1768536
URL: http://svn.apache.org/viewvc?rev=1768536&view=rev
Log:
OAK-5070 - Journal diff not working for changes in bundled node
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.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=1768536&r1=1768535&r2=1768536&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
Mon Nov 7 15:40:49 2016
@@ -35,6 +35,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.json.JsopStream;
+import org.apache.jackrabbit.oak.commons.json.JsopWriter;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.slf4j.Logger;
@@ -277,6 +279,10 @@ public class Commit {
}
}
+ for (String p : bundledNodes.keySet()){
+ markChanged(p);
+ }
+
// push branch changes to journal
if (baseBranchRevision != null) {
// store as external change
@@ -662,27 +668,50 @@ public class Commit {
}
UpdateOp op = operations.get(path);
- //In case its bundled the op would be the one for
- //bundling root
- boolean bundled = isBundled(path);
- if (bundled){
- String bundlingRoot = bundledNodes.get(path);
- op = operations.get(bundlingRoot);
- }
-
- boolean isNew = op != null && op.isNew();
- if (op == null || !hasContentChanges(op) || denotesRoot(path)) {
- // track intermediate node and root
- if (!bundled) {
+ // track _lastRev and apply to cache only when
+ // path is not for a bundled node state
+ if (!isBundled(path)) {
+ boolean isNew = op != null && op.isNew();
+ if (op == null || !hasContentChanges(op) || denotesRoot(path))
{
+ // track intermediate node and root
tracker.track(path);
}
+ nodeStore.applyChanges(before, after, rev, path, isNew,
+ added, removed, changed);
}
- nodeStore.applyChanges(before, after, rev, path, isNew,
- added, removed, changed, cacheEntry);
+ addChangesToDiffCacheEntry(path, added, removed, changed,
cacheEntry);
}
cacheEntry.done();
}
+ /**
+ * Apply the changes of a node to the cache.
+ *
+ * @param path the path
+ * @param added the list of added child nodes
+ * @param removed the list of removed child nodes
+ * @param changed the list of changed child nodes
+ * @param cacheEntry the cache entry changes are added to
+ */
+ private void addChangesToDiffCacheEntry(String path,
+ List<String> added,
+ List<String> removed,
+ List<String> changed,
+ DiffCache.Entry cacheEntry) {
+ // update diff cache
+ JsopWriter w = new JsopStream();
+ for (String p : added) {
+ w.tag('+').key(PathUtils.getName(p)).object().endObject();
+ }
+ for (String p : removed) {
+ w.tag('-').value(PathUtils.getName(p));
+ }
+ for (String p : changed) {
+ w.tag('^').key(PathUtils.getName(p)).object().endObject();
+ }
+ cacheEntry.append(path, w.toString());
+ }
+
private void markChanged(String path) {
if (!denotesRoot(path) && !PathUtils.isAbsolute(path)) {
throw new IllegalArgumentException("path: " + path);
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1768536&r1=1768535&r2=1768536&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Mon Nov 7 15:40:49 2016
@@ -1161,8 +1161,7 @@ public final class DocumentNodeStore
void applyChanges(RevisionVector before, RevisionVector after,
Revision rev, String path,
boolean isNew, List<String> added,
- List<String> removed, List<String> changed,
- DiffCache.Entry cacheEntry) {
+ List<String> removed, List<String> changed) {
if (isNew) {
// determine the revision for the nodeChildrenCache entry when
// the node is new. Fallback to after revision in case document
@@ -1252,19 +1251,6 @@ public final class DocumentNodeStore
}
}
}
-
- // update diff cache
- JsopWriter w = new JsopStream();
- for (String p : added) {
- w.tag('+').key(PathUtils.getName(p)).object().endObject();
- }
- for (String p : removed) {
- w.tag('-').value(PathUtils.getName(p));
- }
- for (String p : changed) {
- w.tag('^').key(PathUtils.getName(p)).object().endObject();
- }
- cacheEntry.append(path, w.toString());
}
/**
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=1768536&r1=1768535&r2=1768536&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
Mon Nov 7 15:40:49 2016
@@ -39,6 +39,7 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
+import org.apache.jackrabbit.oak.plugins.document.PathRev;
import org.apache.jackrabbit.oak.plugins.document.TestNodeObserver;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
@@ -52,7 +53,6 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -511,6 +511,29 @@ public class DocumentBundlingTest {
}
@Test
+ public void bundledNodeAndNodeChildrenCache() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ NodeBuilder appNB = newNode("app:Asset");
+ createChild(appNB,
+ "jcr:content",
+ "jcr:content/comments", //not bundled
+ "jcr:content/metadata",
+ "jcr:content/metadata/xmp", //not bundled
+ "jcr:content/renditions", //includes all
+ "jcr:content/renditions/original",
+ "jcr:content/renditions/original/jcr:content"
+ );
+ builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
+
+ merge(builder);
+
+ Set<PathRev> cachedPaths =
store.getNodeChildrenCache().asMap().keySet();
+ for (PathRev pr : cachedPaths){
+ assertFalse(pr.getPath().contains("jcr:content/renditions"));
+ }
+ }
+
+ @Test
public void recreatedBundledNode() throws Exception{
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
@@ -617,7 +640,6 @@ public class DocumentBundlingTest {
assertFalse(hasNodeProperty("/test/book.jpg", concat("comments",
DocumentBundlor.META_PROP_NODE)));
}
- @Ignore("OAK-5070")
@Test
public void journalDiffAndBundling() throws Exception{
NodeBuilder builder = store.getRoot().builder();