Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/AbstractDocumentNodeState.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/AbstractDocumentNodeState.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/AbstractDocumentNodeState.java (working copy) @@ -39,8 +39,6 @@ public abstract String getPath(); - public abstract RevisionVector getRevision(); - public abstract RevisionVector getLastRevision(); public abstract RevisionVector getRootRevision(); @@ -119,10 +117,9 @@ perfLogger .end(start, 1, - "compareAgainstBaseState, path={}, readRevision={}, lastRevision={}, base.path={}, base.readRevision={}, base.lastRevision={}", - getPath(), getRevision(), getLastRevision(), - mBase.getPath(), mBase.getRevision(), - mBase.getLastRevision()); + "compareAgainstBaseState, path={}, lastRevision={}, base.path={}, base.lastRevision={}", + getPath(), getLastRevision(), + mBase.getPath(), mBase.getLastRevision()); } } } @@ -135,15 +132,14 @@ //------------------------------< internal >-------------------------------- /** - * Returns {@code true} if this state has the same revision as the - * {@code other} state. This method first compares the {@link #readRevision} - * and then the {@link #lastRevision}. + * Returns {@code true} if this state has the same last revision as the + * {@code other} state. * * @param other the other state to compare with. - * @return {@code true} if the revisions are equal, {@code false} otherwise. + * @return {@code true} if the last revisions are equal, {@code false} otherwise. */ private boolean revisionEquals(AbstractDocumentNodeState other) { - return this.getRevision().equals(other.getRevision()) - || this.getLastRevision().equals(other.getLastRevision()); + return this.getLastRevision() != null + && this.getLastRevision().equals(other.getLastRevision()); } } Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (working copy) @@ -71,7 +71,6 @@ static final int MAX_FETCH_SIZE = INITIAL_FETCH_SIZE << 4; final String path; - final RevisionVector readRevision; RevisionVector lastRevision; final RevisionVector rootRevision; final boolean fromExternalChange; @@ -84,29 +83,27 @@ DocumentNodeState(@Nonnull DocumentNodeStore store, @Nonnull String path, - @Nonnull RevisionVector readRevision) { - this(store, path, readRevision, false); + @Nonnull RevisionVector rootRevision) { + this(store, path, rootRevision, false); } DocumentNodeState(@Nonnull DocumentNodeStore store, @Nonnull String path, - @Nonnull RevisionVector readRevision, boolean hasChildren) { - this(store, path, readRevision, new HashMap(), - hasChildren, null, null, false); + @Nonnull RevisionVector rootRevision, boolean hasChildren) { + this(store, path, rootRevision, new HashMap(), + hasChildren, null, false); } private DocumentNodeState(@Nonnull DocumentNodeStore store, @Nonnull String path, - @Nonnull RevisionVector readRevision, + @Nonnull RevisionVector rootRevision, @Nonnull Map properties, boolean hasChildren, @Nullable RevisionVector lastRevision, - @Nullable RevisionVector rootRevision, boolean fromExternalChange) { this.store = checkNotNull(store); this.path = checkNotNull(path); - this.readRevision = checkNotNull(readRevision); + this.rootRevision = checkNotNull(rootRevision); this.lastRevision = lastRevision; - this.rootRevision = rootRevision != null ? rootRevision : readRevision; this.fromExternalChange = fromExternalChange; this.hasChildren = hasChildren; this.properties = checkNotNull(properties); @@ -131,8 +128,8 @@ if (rootRevision.equals(root) && fromExternalChange == externalChange) { return this; } else { - return new DocumentNodeState(store, path, readRevision, properties, - hasChildren, lastRevision, root, externalChange); + return new DocumentNodeState(store, path, root, properties, + hasChildren, lastRevision, externalChange); } } @@ -142,8 +139,8 @@ */ @Nonnull DocumentNodeState fromExternalChange() { - return new DocumentNodeState(store, path, readRevision, properties, hasChildren, - lastRevision, rootRevision, true); + return new DocumentNodeState(store, path, rootRevision, properties, hasChildren, + lastRevision, true); } /** @@ -157,22 +154,13 @@ //--------------------------< AbstractDocumentNodeState >----------------------------------- - @Override - @Nonnull - public RevisionVector getRevision() { - return readRevision; - } - /** - * Returns the root revision for this node state. This is the read revision + * Returns the root revision for this node state. This is the root revision * passed from the parent node state. This revision therefore reflects the * revision of the root node state where the traversal down the tree - * started. The returned revision is only maintained on a best effort basis - * and may be the same as {@link #getRevision()} if this node state is - * retrieved directly from the {@code DocumentNodeStore}. + * started. * - * @return the revision of the root node state is available, otherwise the - * same value as returned by {@link #getRevision()}. + * @return the revision of the root node state. */ @Nonnull public RevisionVector getRootRevision() { @@ -285,9 +273,9 @@ @Override public NodeBuilder builder() { if ("/".equals(getPath())) { - if (readRevision.isBranch()) { + if (getRootRevision().isBranch()) { // check if this node state is head of a branch - Branch b = store.getBranches().getBranch(readRevision); + Branch b = store.getBranches().getBranch(getRootRevision()); if (b == null) { if (store.isDisableBranches()) { if (DocumentNodeStoreBranch.getCurrentBranch() != null) { @@ -296,10 +284,10 @@ return new MemoryNodeBuilder(this); } } else { - throw new IllegalStateException("No branch for revision: " + readRevision); + throw new IllegalStateException("No branch for revision: " + getRootRevision()); } } - if (b.isHead(readRevision.getBranchRevision()) + if (b.isHead(getRootRevision().getBranchRevision()) && DocumentNodeStoreBranch.getCurrentBranch() != null) { return new DocumentRootBuilder(this, store); } else { @@ -360,7 +348,8 @@ public String toString() { StringBuilder buff = new StringBuilder(); buff.append("{ path: '").append(path).append("', "); - buff.append("readRevision: '").append(readRevision).append("', "); + buff.append("rootRevision: '").append(rootRevision).append("', "); + buff.append("lastRevision: '").append(lastRevision).append("', "); buff.append("properties: '").append(properties.values()).append("' }"); return buff.toString(); } @@ -397,7 +386,6 @@ @Override public int getMemory() { int size = 40 // shallow - + readRevision.getMemory() + (lastRevision != null ? lastRevision.getMemory() : 0) + rootRevision.getMemory() + estimateMemoryUsage(path); @@ -490,7 +478,7 @@ public String asString() { JsopWriter json = new JsopBuilder(); json.key("path").value(path); - json.key("rev").value(readRevision.toString()); + json.key("rev").value(rootRevision.toString()); if (lastRevision != null) { json.key("lastRev").value(lastRevision.toString()); } @@ -510,10 +498,10 @@ public static DocumentNodeState fromString(DocumentNodeStore store, String s) { JsopTokenizer json = new JsopTokenizer(s); String path = null; - RevisionVector rev = null; + RevisionVector rootRev = null; RevisionVector lastRev = null; boolean hasChildren = false; - DocumentNodeState state = null; + DocumentNodeState state; HashMap map = new HashMap(); while (true) { String k = json.readString(); @@ -521,7 +509,7 @@ if ("path".equals(k)) { path = json.readString(); } else if ("rev".equals(k)) { - rev = RevisionVector.fromString(json.readString()); + rootRev = RevisionVector.fromString(json.readString()); } else if ("lastRev".equals(k)) { lastRev = RevisionVector.fromString(json.readString()); } else if ("hasChildren".equals(k)) { @@ -544,7 +532,7 @@ } json.read(','); } - state = new DocumentNodeState(store, path, rev, hasChildren); + state = new DocumentNodeState(store, path, rootRev, hasChildren); state.setLastRevision(lastRev); for (Entry e : map.entrySet()) { state.setProperty(e.getKey(), e.getValue()); Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (working copy) @@ -511,7 +511,7 @@ initializeRootState(rootDoc); // check if _lastRev for our clusterId exists if (!rootDoc.getLastRev().containsKey(clusterId)) { - unsavedLastRevisions.put("/", getRoot().getRevision().getRevision(clusterId)); + unsavedLastRevisions.put("/", getRoot().getRootRevision().getRevision(clusterId)); if (!readOnlyMode) { backgroundWrite(); } @@ -1653,7 +1653,7 @@ @Nonnull public RevisionVector getHeadRevision() { - return root.getRevision(); + return root.getRootRevision(); } @Nonnull @@ -2425,7 +2425,7 @@ @Override public String getHead(){ - return getRoot().getRevision().toString(); + return getRoot().getRootRevision().toString(); } @Override Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java (working copy) @@ -286,7 +286,7 @@ DocumentNodeState base, CommitInfo info) { boolean success = false; - Commit c = store.newCommit(base.getRevision(), this); + Commit c = store.newCommit(base.getRootRevision(), this); RevisionVector rev; try { op.with(c); @@ -296,7 +296,7 @@ return base; } c.apply(); - rev = store.done(c, base.getRevision().isBranch(), info); + rev = store.done(c, base.getRootRevision().isBranch(), info); success = true; } finally { if (!success) { @@ -561,7 +561,7 @@ * @return the branch state. */ final DocumentNodeState createBranch(DocumentNodeState state) { - return store.getRoot(state.getRevision().asBranchRevision(store.getClusterId())); + return store.getRoot(state.getRootRevision().asBranchRevision(store.getClusterId())); } @Override @@ -581,7 +581,7 @@ void rebase() { DocumentNodeState root = store.getRoot(); // perform rebase in store - head = store.getRoot(store.rebase(head.getRevision(), root.getRevision())); + head = store.getRoot(store.rebase(head.getRootRevision(), root.getRootRevision())); base = root; } @@ -603,7 +603,7 @@ checkForConflicts(); NodeState toCommit = checkNotNull(hook).processCommit(base, head, info); head = DocumentNodeStoreBranch.this.persist(toCommit, head, info); - return store.getRoot(store.merge(head.getRevision(), info)); + return store.getRoot(store.merge(head.getRootRevision(), info)); } }); branchState = new Merged(base); @@ -633,8 +633,8 @@ private void resetBranch(DocumentNodeState branchHead, DocumentNodeState ancestor) { try { head = store.getRoot( - store.reset(branchHead.getRevision(), - ancestor.getRevision())); + store.reset(branchHead.getRootRevision(), + ancestor.getRootRevision())); } catch (Exception e) { CommitFailedException ex = new CommitFailedException( OAK, 100, "Branch reset failed", e); @@ -650,7 +650,7 @@ * of the commits on this branch. */ private void checkForConflicts() throws CommitFailedException { - Branch b = store.getBranches().getBranch(head.getRevision()); + Branch b = store.getBranches().getBranch(head.getRootRevision()); if (b == null) { return; } Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeState.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeState.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeState.java (working copy) @@ -63,7 +63,6 @@ private final RevisionVector rootRevision; private final boolean fromExternalChange; private RevisionVector lastRevision; - private RevisionVector readRevision; private String path; /** @@ -105,7 +104,6 @@ this.rootRevision = rootRevision; this.fromExternalChange = fromExternalChange; this.path = original.path; - this.readRevision = original.readRevision; this.lastRevision = original.lastRevision; } @@ -120,14 +118,6 @@ } @Override - public RevisionVector getRevision() { - if (readRevision == null){ - this.readRevision = RevisionVector.fromString(getRequiredProp(PROP_REVISION)); - } - return readRevision; - } - - @Override public RevisionVector getLastRevision() { if (lastRevision == null){ this.lastRevision = RevisionVector.fromString(getRequiredProp(PROP_LAST_REV)); Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/PathFilteringDiff.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/PathFilteringDiff.java (revision 1753661) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/PathFilteringDiff.java (working copy) @@ -101,7 +101,7 @@ } static void copyMetaProperties(AbstractDocumentNodeState state, NodeBuilder builder) { - builder.setProperty(asPropertyState(PROP_REVISION, state.getRevision())); + builder.setProperty(asPropertyState(PROP_REVISION, state.getRootRevision())); builder.setProperty(asPropertyState(PROP_LAST_REV, state.getLastRevision())); builder.setProperty(createProperty(PROP_PATH, state.getPath())); } Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterRevisionComparisonTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterRevisionComparisonTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterRevisionComparisonTest.java (working copy) @@ -145,7 +145,7 @@ // read again starting at root node with a invalidated cache // and purged revision comparator c1ns1 = c1.getRoot(); - c1.invalidateNodeCache("/", c1ns1.getRevision()); + c1.invalidateNodeCache("/", c1ns1.getRootRevision()); c1ns1 = c1.getRoot(); c1.invalidateNodeCache("/a", c1ns1.getLastRevision()); assertTrue("/a missing", c1ns1.hasChildNode("a")); Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java (working copy) @@ -76,7 +76,7 @@ @Override public void contentChanged(@Nonnull NodeState root, @Nullable CommitInfo info) { DocumentNodeState after = (DocumentNodeState) root; - RevisionVector r = after.getRevision(); + RevisionVector r = after.getRootRevision(); LOG.debug("seen: {}", r); if (r.compareTo(before) < 0) { exceptions.add(new Exception( Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStateTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStateTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStateTest.java (working copy) @@ -35,7 +35,7 @@ DocumentNodeStore store = builderProvider.newBuilder().getNodeStore(); RevisionVector rv = new RevisionVector(Revision.newRevision(1)); DocumentNodeState state = new DocumentNodeState(store, "/foo", rv); - assertEquals(232, state.getMemory()); + assertEquals(164, state.getMemory()); } @Test Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (working copy) @@ -1670,14 +1670,10 @@ merge(ns2, b2); // on cluster node 2, remove of child-0 is not yet visible - List children = Lists.newArrayList(ns2.getRoot().getChildNode("foo").getChildNode("bar").getChildNodeEntries()); + DocumentNodeState bar = asDocumentNodeState(ns2.getRoot().getChildNode("foo").getChildNode("bar")); + List children = Lists.newArrayList(bar.getChildNodeEntries()); assertEquals(2, Iterables.size(children)); - RevisionVector invalidate = null; - for (ChildNodeEntry entry : children) { - if (entry.getName().equals("child-0")) { - invalidate = asDocumentNodeState(entry.getNodeState()).getRevision(); - } - } + RevisionVector invalidate = bar.getLastRevision(); assertNotNull(invalidate); // this will make changes from cluster node 1 visible @@ -2227,7 +2223,7 @@ afterTest.compareAgainstBaseState(beforeTest, new DefaultNodeStateDiff()); assertEquals(1, startValues.size()); - Revision localHead = before.getRevision().getRevision(ns.getClusterId()); + Revision localHead = before.getRootRevision().getRevision(ns.getClusterId()); assertNotNull(localHead); long beforeModified = getModifiedInSecs(localHead.getTimestamp()); // startValue must be based on the revision of the before state Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java (working copy) @@ -226,7 +226,7 @@ private void prRev(NodeState ns){ if(ns instanceof DocumentNodeState){ DocumentNodeState dns = ((DocumentNodeState) ns); - LOG.info("Root at {} ({})", dns.getRevision(), dns.getLastRevision()); + LOG.info("Root at {} ({})", dns.getRootRevision(), dns.getLastRevision()); } } Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java (working copy) @@ -477,7 +477,7 @@ } // invalidate cached DocumentNodeState DocumentNodeState state = (DocumentNodeState) store.getRoot().getChildNode(name); - store.invalidateNodeCache(state.getPath(), state.getRevision()); + store.invalidateNodeCache(state.getPath(), store.getRoot().getLastRevision()); while (!f.isDone()) { docs.poll(); Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeStateTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeStateTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/DelegatingDocumentNodeStateTest.java (working copy) @@ -52,7 +52,6 @@ builder.setProperty(createProperty(PROP_PATH, "foo")); AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER); - assertEquals(rv1, state.getRevision()); assertEquals(rv1, state.getRootRevision()); assertEquals(rv2, state.getLastRevision()); assertEquals("foo", state.getPath()); Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java (revision 1753661) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java (working copy) @@ -141,7 +141,7 @@ } private static void assertMetaState(AbstractDocumentNodeState a, AbstractDocumentNodeState b){ - assertEquals(a.getRevision(), b.getRevision()); + assertEquals(a.getLastRevision(), b.getLastRevision()); assertEquals(a.getRootRevision(), b.getRootRevision()); assertEquals(a.getPath(), b.getPath()); }