jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1450828 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/kernel/ main/java/org/apache/jackrabbit/oak/plugins/memory/ main/java/org/apache/jackrabbit/oak/plugins/segment/...
Date Wed, 27 Feb 2013 16:18:46 GMT
Author: mduerig
Date: Wed Feb 27 16:18:46 2013
New Revision: 1450828

URL: http://svn.apache.org/r1450828
Log:
OAK-609: Rename 'root' methods in NodeStore and NodeStoreBranch

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilderTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Wed Feb 27 16:18:46 2013
@@ -376,7 +376,7 @@ public class RootImpl implements Root {
     }
 
     NodeBuilder createRootBuilder() {
-        return branch.getRoot().builder();
+        return branch.getHead().builder();
     }
 
     // TODO better way to determine purge limit. See OAK-175
@@ -405,7 +405,7 @@ public class RootImpl implements Root {
      * Reset the root builder to the branch's current root state
      */
     private void reset() {
-        rootTree.getNodeBuilder().reset(branch.getRoot());
+        rootTree.getNodeBuilder().reset(branch.getHead());
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Wed Feb 27 16:18:46 2013
@@ -71,7 +71,7 @@ class KernelNodeStoreBranch implements N
     }
 
     @Override
-    public NodeState getRoot() {
+    public NodeState getHead() {
         checkNotMerged();
         return head;
     }
@@ -80,7 +80,7 @@ class KernelNodeStoreBranch implements N
     public void setRoot(NodeState newRoot) {
         checkNotMerged();
         if (!head.equals(newRoot)) {
-            NodeState oldRoot = head;
+            NodeState oldHead = head;
             head = newRoot;
             if (++updates > 1) {
                 // persist unless this is the first update
@@ -90,7 +90,7 @@ class KernelNodeStoreBranch implements N
                     success = true;
                 } finally {
                     if (!success) {
-                        head = oldRoot;
+                        head = oldHead;
                     }
                 }
             }
@@ -143,7 +143,7 @@ class KernelNodeStoreBranch implements N
     public NodeState merge(CommitHook hook) throws CommitFailedException {
         checkNotMerged();
         NodeState toCommit = checkNotNull(hook).processCommit(base, head);
-            NodeState oldRoot = head;
+        NodeState oldRoot = head;
         head = toCommit;
 
         try {
@@ -189,7 +189,7 @@ class KernelNodeStoreBranch implements N
             // Nothing written to persistent branch yet
             // perform rebase in memory
             NodeBuilder builder = new MemoryNodeBuilder(root);
-            getRoot().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
+            getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
             head = builder.getNodeState();
             base = root;
             baseRevision = root.getRevision();
@@ -211,7 +211,7 @@ class KernelNodeStoreBranch implements N
 
     private NodeState getNode(String path) {
         checkArgument(path.startsWith("/"));
-        NodeState node = getRoot();
+        NodeState node = getHead();
         for (String name : elements(path)) {
             node = node.getChildNode(name);
             if (node == null) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Wed Feb 27 16:18:46 2013
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.concurrent.atomic.AtomicReference;
@@ -30,6 +27,9 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
 /**
  * Basic in-memory node store implementation. Useful as a base class for
  * more complex functionality.
@@ -85,7 +85,7 @@ public class MemoryNodeStore implements 
         }
 
         @Override
-        public NodeState getRoot() {
+        public NodeState getHead() {
             checkNotMerged();
             return root;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Wed Feb 27 16:18:46 2013
@@ -58,7 +58,7 @@ class SegmentNodeStoreBranch implements 
     }
 
     @Override @Nonnull
-    public synchronized NodeState getRoot() {
+    public synchronized NodeState getHead() {
         return new SegmentNodeState(reader, rootId);
     }
 
@@ -74,7 +74,7 @@ class SegmentNodeStoreBranch implements 
         if (!baseId.equals(newBaseId)) {
             NodeBuilder builder =
                     new MemoryNodeBuilder(new SegmentNodeState(reader, newBaseId));
-            getRoot().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
+            getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
             this.baseId = newBaseId;
             this.rootId = writer.writeNode(builder.getNodeState()).getRecordId();
             writer.flush();
@@ -91,14 +91,14 @@ class SegmentNodeStoreBranch implements 
             // rebase to latest head and apply commit hooks
             rebase();
             RecordId headId = writer.writeNode(
-                    hook.processCommit(getBase(), getRoot())).getRecordId();
+                    hook.processCommit(getBase(), getHead())).getRecordId();
             writer.flush();
 
             // use optimistic locking to update the journal
             if (store.setJournalHead(journal, headId, baseId)) {
                 baseId = headId;
                 rootId = headId;
-                return getRoot();
+                return getHead();
             }
 
             // someone else was faster, so clear state and try again later
@@ -124,7 +124,7 @@ class SegmentNodeStoreBranch implements 
             return true;
         }
 
-        NodeBuilder builder = getRoot().builder();
+        NodeBuilder builder = getHead().builder();
 
         NodeBuilder targetBuilder = builder;
         String targetParent = PathUtils.getParentPath(target);
@@ -164,7 +164,7 @@ class SegmentNodeStoreBranch implements 
 
     @Override
     public boolean copy(String source, String target) {
-        NodeBuilder builder = getRoot().builder();
+        NodeBuilder builder = getHead().builder();
 
         NodeBuilder targetBuilder = builder;
         String targetParent = PathUtils.getParentPath(target);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
Wed Feb 27 16:18:46 2013
@@ -35,7 +35,7 @@ public class OakInitializer {
                                   @Nonnull RepositoryInitializer initializer,
                                   @Nonnull IndexHookProvider indexHook) {
         NodeStoreBranch branch = store.branch();
-        NodeState before = branch.getRoot();
+        NodeState before = branch.getHead();
         branch.setRoot(initializer.initialize(before));
         try {
             branch.merge(IndexHookManager.of(indexHook));
@@ -51,7 +51,7 @@ public class OakInitializer {
                                   @Nonnull QueryIndexProvider indexProvider,
                                   @Nonnull CommitHook commitHook) {
         NodeStoreBranch branch = store.branch();
-        NodeState root = branch.getRoot();
+        NodeState root = branch.getHead();
         for (WorkspaceInitializer wspInit : initializer) {
             root = wspInit.initialize(root, workspaceName, indexHook, indexProvider, commitHook);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
Wed Feb 27 16:18:46 2013
@@ -30,6 +30,8 @@ public interface NodeStoreBranch {
 
     /**
      * Returns the base state of this branch.
+     * The base state is the state of the tree as it was at the time
+     * {@link NodeStore#branch()} was used to obtain this instance.
      *
      * @return root node state
      */
@@ -37,13 +39,17 @@ public interface NodeStoreBranch {
     NodeState getBase();
 
     /**
-     * Returns the latest state of the branch.
+     * Returns the head state of this branch.
+     * The head state is the state resulting from the
+     * base state by applying all subsequent modifications to this branch
+     * by {@link #setRoot(NodeState)}, {@link #move(String, String)},
+     * and {@link #copy(String, String)}.
      *
      * @return root node state
      * @throws IllegalStateException if the branch is already merged
      */
     @Nonnull
-    NodeState getRoot();
+    NodeState getHead();
 
     /**
      * Updates the state of the content tree of this private branch.

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilderTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilderTest.java
Wed Feb 27 16:18:46 2013
@@ -49,7 +49,7 @@ public class KernelNodeBuilderTest {
 
     private static void init(NodeStore store) throws CommitFailedException {
         NodeStoreBranch branch = store.branch();
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
         builder.child("x").child("y").child("z");
         branch.setRoot(builder.getNodeState());
         branch.merge(EmptyHook.INSTANCE);
@@ -57,7 +57,7 @@ public class KernelNodeBuilderTest {
 
     private static void run(NodeStore store) throws CommitFailedException {
         NodeStoreBranch branch = store.branch();
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
 
         assertTrue("child node x should be present", builder.hasChildNode("x"));
         assertTrue("child node x/y should be present", builder.child("x")

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
Wed Feb 27 16:18:46 2013
@@ -50,7 +50,7 @@ public class KernelNodeStateTest {
         NodeStore store = new KernelNodeStore(new MicroKernelImpl());
         NodeStoreBranch branch = store.branch();
 
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
         builder.setProperty("a", 1);
         builder.setProperty("b", 2);
         builder.setProperty("c", 3);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
Wed Feb 27 16:18:46 2013
@@ -56,7 +56,7 @@ public class KernelNodeStoreCacheTest {
         store = new KernelNodeStore(wrapper);
         NodeStoreBranch branch = store.branch();
 
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
         builder.child("a");
         NodeBuilder b = builder.child("b");
         b.child("c");
@@ -140,7 +140,7 @@ public class KernelNodeStoreCacheTest {
 
     private void modifyContent() throws Exception {
         NodeStoreBranch branch = store.branch();
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
         builder.child("a").setProperty("foo", "bar");
         branch.setRoot(builder.getNodeState());
         branch.merge(EmptyHook.INSTANCE);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
Wed Feb 27 16:18:46 2013
@@ -70,7 +70,7 @@ public class KernelNodeStoreTest {
     public void branch() throws CommitFailedException {
         NodeStoreBranch branch = store.branch();
 
-        NodeBuilder rootBuilder = branch.getRoot().builder();
+        NodeBuilder rootBuilder = branch.getHead().builder();
         NodeBuilder testBuilder = rootBuilder.child("test");
         NodeBuilder newNodeBuilder = testBuilder.child("newNode");
 
@@ -85,14 +85,14 @@ public class KernelNodeStoreTest {
         assertEquals(42, (long) testState.getChildNode("newNode").getProperty("n").getValue(LONG));
 
         // Assert changes are not yet present in the branch
-        testState = branch.getRoot().getChildNode("test");
+        testState = branch.getHead().getChildNode("test");
         assertNull(testState.getChildNode("newNode"));
         assertNotNull(testState.getChildNode("x"));
 
         branch.setRoot(rootBuilder.getNodeState());
 
         // Assert changes are present in the branch
-        testState = branch.getRoot().getChildNode("test");
+        testState = branch.getHead().getChildNode("test");
         assertNotNull(testState.getChildNode("newNode"));
         assertNull(testState.getChildNode("x"));
         assertEquals(42, (long) testState.getChildNode("newNode").getProperty("n").getValue(LONG));

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
Wed Feb 27 16:18:46 2013
@@ -45,7 +45,7 @@ public class LargeKernelNodeStateTest {
         NodeStore store = new KernelNodeStore(new MicroKernelImpl());
         NodeStoreBranch branch = store.branch();
 
-        NodeBuilder builder = branch.getRoot().builder();
+        NodeBuilder builder = branch.getHead().builder();
         builder.setProperty("a", 1);
         for (int i = 0; i <= N; i++) {
             builder.child("x" + i);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java?rev=1450828&r1=1450827&r2=1450828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
Wed Feb 27 16:18:46 2013
@@ -67,7 +67,7 @@ public class NodeTypeIndexTest {
     @Test
     public void nodeType() throws Exception {
         NodeStoreBranch branch = store.branch();
-        NodeBuilder root = branch.getRoot().builder();
+        NodeBuilder root = branch.getHead().builder();
 
         root.removeNode("rep:security"); // interferes with tests
         addFolder(root, "folder-1");



Mime
View raw message