Author: mreutegg
Date: Tue Mar 11 17:41:01 2014
New Revision: 1576432
URL: http://svn.apache.org/r1576432
Log:
OAK-1429: Slow event listeners do not scale as expected
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java?rev=1576432&r1=1576431&r2=1576432&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
Tue Mar 11 17:41:01 2014
@@ -362,9 +362,7 @@ public final class NodeDocument extends
*/
@CheckForNull
public String getCommitRootPath(Revision revision) {
- // check local map first
- Map<Revision, String> local = getLocalCommitRoot();
- String depth = local.get(revision);
+ String depth = getCommitRootDepth(revision);
if (depth != null) {
if (depth.equals("0")) {
return "/";
@@ -373,13 +371,6 @@ public final class NodeDocument extends
return PathUtils.getAncestorPath(p,
PathUtils.getDepth(p) - Integer.parseInt(depth));
}
- // check previous
- for (NodeDocument prev : getPreviousDocs(COMMIT_ROOT, revision)) {
- String path = prev.getCommitRootPath(revision);
- if (path != null) {
- return path;
- }
- }
return null;
}
@@ -968,6 +959,31 @@ public final class NodeDocument extends
}
/**
+ * Returns the commit root depth for the given revision. This method also
+ * takes previous documents into account.
+ *
+ * @param revision get the commit root depth for this revision.
+ * @return the depth or <code>null</code> if there is no commit root entry
+ * for the given revision on this document or previous documents.
+ */
+ @CheckForNull
+ private String getCommitRootDepth(@Nonnull Revision revision) {
+ // check local map first
+ Map<Revision, String> local = getLocalCommitRoot();
+ String depth = local.get(revision);
+ if (depth == null) {
+ // check previous
+ for (NodeDocument prev : getPreviousDocs(COMMIT_ROOT, revision)) {
+ depth = prev.getCommitRootDepth(revision);
+ if (depth != null) {
+ break;
+ }
+ }
+ }
+ return depth;
+ }
+
+ /**
* Checks that revision x is newer than another revision.
*
* @param x the revision to check
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java?rev=1576432&r1=1576431&r2=1576432&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
Tue Mar 11 17:41:01 2014
@@ -277,6 +277,27 @@ public class DocumentSplitTest extends B
}
}
+ @Test
+ public void commitRootInPrevious() {
+ DocumentStore store = mk.getDocumentStore();
+ DocumentNodeStore ns = mk.getNodeStore();
+ mk.commit("/", "+\"test\":{\"node\":{}}", null, null);
+ mk.commit("/test", "+\"foo\":{}+\"bar\":{}", null, null);
+ mk.commit("/test", "^\"foo/prop\":0^\"bar/prop\":0", null, null);
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ assertNotNull(doc);
+ String rev = null;
+ for (int i = 0; i < NodeDocument.NUM_REVS_THRESHOLD; i++) {
+ rev = mk.commit("/test/foo", "^\"prop\":" + i, null, null);
+ }
+ ns.runBackgroundOperations();
+ doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ assertNotNull(doc);
+ DocumentNodeState node = doc.getNodeAtRevision(ns,
+ Revision.fromString(rev), null);
+ assertNotNull(node);
+ }
+
private void syncMKs(List<DocumentMK> mks, int idx) {
mks.get(idx).runBackgroundOperations();
for (int i = 0; i < mks.size(); i++) {