jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1525095 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/ oa...
Date Fri, 20 Sep 2013 18:48:58 GMT
Author: jukka
Date: Fri Sep 20 18:48:58 2013
New Revision: 1525095

URL: http://svn.apache.org/r1525095
Log:
OAK-659: Move purge logic for transient changes below the NodeBuilder interface

Use builders instead of branches

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1525095&r1=1525094&r2=1525095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
Fri Sep 20 18:48:58 2013
@@ -36,7 +36,6 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -88,8 +87,7 @@ public class AsyncIndexUpdate implements
 
         preAsyncRun(store);
 
-        NodeStoreBranch branch = store.branch();
-        NodeBuilder builder = branch.getHead().builder();
+        NodeBuilder builder = store.getRoot().builder();
         NodeBuilder async = builder.child(ASYNC);
 
         NodeState before = null;
@@ -107,8 +105,7 @@ public class AsyncIndexUpdate implements
             try {
                 async.setProperty(name, checkpoint);
                 postAsyncRunStatus(builder);
-                branch.setRoot(builder.getNodeState());
-                branch.merge(new CommitHook() {
+                store.merge(builder, new CommitHook() {
                     @Override
                     @Nonnull
                     public NodeState processCommit(NodeState before,
@@ -144,12 +141,10 @@ public class AsyncIndexUpdate implements
     }
 
     private void preAsyncRun(NodeStore store) {
-        NodeStoreBranch branch = store.branch();
-        NodeBuilder builder = branch.getHead().builder();
+        NodeBuilder builder = store.getRoot().builder();
         preAsyncRunStatus(builder);
-        branch.setRoot(builder.getNodeState());
         try {
-            branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+            store.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
         } catch (CommitFailedException e) {
             log.warn("Index status update {} failed", name, e);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java?rev=1525095&r1=1525094&r2=1525095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
Fri Sep 20 18:48:58 2013
@@ -34,7 +34,6 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -73,21 +72,18 @@ public class AsyncIndexUpdateTest {
         NodeStore store = new MemoryNodeStore();
         IndexEditorProvider provider = new PropertyIndexEditorProvider();
 
-        NodeStoreBranch branch = store.branch();
-        NodeState root = branch.getHead();
-        NodeBuilder builder = root.builder();
+        NodeBuilder builder = store.getRoot().builder();
         createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
                 "rootIndex", true, false, ImmutableSet.of("foo"), null)
                 .setProperty(ASYNC_PROPERTY_NAME, "async");
         builder.child("testRoot").setProperty("foo", "abc");
 
         // merge it back in
-        branch.setRoot(builder.getNodeState());
-        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        store.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
         async.run();
-        root = store.getRoot();
+        NodeState root = store.getRoot();
 
         // first check that the index content nodes exist
         checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex",
@@ -111,9 +107,7 @@ public class AsyncIndexUpdateTest {
         NodeStore store = new MemoryNodeStore();
         IndexEditorProvider provider = new PropertyIndexEditorProvider();
 
-        NodeStoreBranch branch = store.branch();
-        NodeState root = branch.getHead();
-        NodeBuilder builder = root.builder();
+        NodeBuilder builder = store.getRoot().builder();
         createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
                 "rootIndex", true, false, ImmutableSet.of("foo"), null)
                 .setProperty(ASYNC_PROPERTY_NAME, "async");
@@ -126,12 +120,11 @@ public class AsyncIndexUpdateTest {
         builder.child("testSecond").setProperty("bar", "ghi");
 
         // merge it back in
-        branch.setRoot(builder.getNodeState());
-        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        store.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
         async.run();
-        root = store.getRoot();
+        NodeState root = store.getRoot();
 
         // first check that the index content nodes exist
         checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex",
@@ -164,9 +157,7 @@ public class AsyncIndexUpdateTest {
         NodeStore store = new MemoryNodeStore();
         IndexEditorProvider provider = new PropertyIndexEditorProvider();
 
-        NodeStoreBranch branch = store.branch();
-        NodeState root = branch.getHead();
-        NodeBuilder builder = root.builder();
+        NodeBuilder builder = store.getRoot().builder();
         createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
                 "rootIndex", true, false, ImmutableSet.of("foo"), null)
                 .setProperty(ASYNC_PROPERTY_NAME, "async");
@@ -181,12 +172,11 @@ public class AsyncIndexUpdateTest {
                 .setProperty("foo", "xyz");
 
         // merge it back in
-        branch.setRoot(builder.getNodeState());
-        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        store.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
         async.run();
-        root = store.getRoot();
+        NodeState root = store.getRoot();
 
         // first check that the index content nodes exist
         checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex",

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=1525095&r1=1525094&r2=1525095&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
Fri Sep 20 18:48:58 2013
@@ -47,7 +47,6 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.query.Cursors;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -70,8 +69,7 @@ public class NodeTypeIndexTest {
 
     @Test
     public void nodeType() throws Exception {
-        NodeStoreBranch branch = store.branch();
-        NodeBuilder root = branch.getHead().builder();
+        NodeBuilder root = store.getRoot().builder();
 
         // remove "rep:security" as it interferes with tests
         root.getChildNode("rep:security").remove(); 
@@ -80,8 +78,7 @@ public class NodeTypeIndexTest {
         addFolder(root, "folder-2");
         addFile(root, "file-1");
 
-        branch.setRoot(root.getNodeState());
-        branch.merge(new EditorHook(new IndexUpdateProvider(
+        store.merge(root, new EditorHook(new IndexUpdateProvider(
                 new PropertyIndexEditorProvider())), PostCommitHook.EMPTY);
 
         NodeState rootState = store.getRoot();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java?rev=1525095&r1=1525094&r2=1525095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java
Fri Sep 20 18:48:58 2013
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.junit.Test;
 
 public class JournalTest {
@@ -48,9 +47,7 @@ public class JournalTest {
         builder.setProperty("foo", "bar");
         NodeState newState = builder.getNodeState();
 
-        NodeStoreBranch branch = root.branch();
-        branch.setRoot(newState);
-        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        root.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertEquals(newState, root.getRoot());
         assertEquals(oldState, left.getRoot());
@@ -77,9 +74,7 @@ public class JournalTest {
         builder.setProperty("foo", "bar");
         NodeState newState = builder.getNodeState();
 
-        NodeStoreBranch branch = left.branch();
-        branch.setRoot(newState);
-        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        left.merge(builder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertEquals(oldState, root.getRoot());
         assertEquals(newState, left.getRoot());
@@ -106,9 +101,7 @@ public class JournalTest {
         leftBuilder.setProperty("foo", "bar");
         NodeState leftState = leftBuilder.getNodeState();
 
-        NodeStoreBranch leftBranch = left.branch();
-        leftBranch.setRoot(leftState);
-        leftBranch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        left.merge(leftBuilder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertEquals(oldState, root.getRoot());
         assertEquals(leftState, left.getRoot());
@@ -121,11 +114,8 @@ public class JournalTest {
 
         NodeBuilder rightBuilder = oldState.builder();
         rightBuilder.setProperty("bar", "foo");
-        NodeState rightState = rightBuilder.getNodeState();
 
-        NodeStoreBranch rightBranch = right.branch();
-        rightBranch.setRoot(rightState);
-        rightBranch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        right.merge(rightBuilder, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         store.getJournal("right").merge();
         NodeState newState = root.getRoot();
@@ -138,6 +128,6 @@ public class JournalTest {
         assertEquals(newState, root.getRoot());
         assertEquals(newState, left.getRoot());
         assertEquals(newState, right.getRoot());
-}
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java?rev=1525095&r1=1525094&r2=1525095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/MergeTest.java
Fri Sep 20 18:48:58 2013
@@ -45,16 +45,16 @@ public class MergeTest {
         assertFalse(store.getRoot().hasProperty("foo"));
         assertFalse(store.getRoot().hasProperty("bar"));
 
-        NodeStoreBranch a = store.branch();
-        a.setRoot(a.getHead().builder().setProperty("foo", "abc").getNodeState());
-        a.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        NodeBuilder a = store.getRoot().builder();
+        a.setProperty("foo", "abc");
+        store.merge(a, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertTrue(store.getRoot().hasProperty("foo"));
         assertFalse(store.getRoot().hasProperty("bar"));
 
-        NodeStoreBranch b = store.branch();
-        b.setRoot(b.getHead().builder().setProperty("bar", "xyz").getNodeState());
-        b.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        NodeBuilder b = store.getRoot().builder();
+        b.setProperty("bar", "xyz");
+        store.merge(b, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertTrue(store.getRoot().hasProperty("foo"));
         assertTrue(store.getRoot().hasProperty("bar"));
@@ -64,21 +64,21 @@ public class MergeTest {
     public void testOptimisticMerge() throws CommitFailedException {
         NodeStore store = new SegmentNodeStore(new MemoryStore());
 
-        NodeStoreBranch a = store.branch();
-        a.setRoot(a.getHead().builder().setProperty("foo", "abc").getNodeState());
+        NodeBuilder a = store.getRoot().builder();
+        a.setProperty("foo", "abc");
 
-        NodeStoreBranch b = store.branch();
-        b.setRoot(b.getHead().builder().setProperty("bar", "xyz").getNodeState());
+        NodeBuilder b = store.getRoot().builder();
+        b.setProperty("bar", "xyz");
 
         assertFalse(store.getRoot().hasProperty("foo"));
         assertFalse(store.getRoot().hasProperty("bar"));
 
-        a.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        store.merge(a, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertTrue(store.getRoot().hasProperty("foo"));
         assertFalse(store.getRoot().hasProperty("bar"));
 
-        b.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        store.merge(b, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
 
         assertTrue(store.getRoot().hasProperty("foo"));
         assertTrue(store.getRoot().hasProperty("bar"));

Modified: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java?rev=1525095&r1=1525094&r2=1525095&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
(original)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
Fri Sep 20 18:48:58 2013
@@ -168,16 +168,14 @@ public class RepositoryUpgrade {
                 "Copying repository content from {} to Oak",
                 source.getRepositoryConfig().getHomeDir());
         try {
-            NodeStoreBranch branch = target.branch();
-            NodeBuilder builder = branch.getHead().builder();
+            NodeBuilder builder = target.getRoot().builder();
 
             copyNamespaces(builder);
             copyNodeTypes(builder);
             copyVersionStore(builder);
             copyWorkspaces(builder);
 
-            branch.setRoot(builder.getNodeState());
-            branch.merge(new EditorHook(new RegistrationEditorProvider()), PostCommitHook.EMPTY);
// TODO: default hooks?
+            target.merge(builder, new EditorHook(new RegistrationEditorProvider()), PostCommitHook.EMPTY);
// TODO: default hooks?
         } catch (Exception e) {
             throw new RepositoryException("Failed to copy content", e);
         }



Mime
View raw message