jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1374342 - 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/spi/state/ test/...
Date Fri, 17 Aug 2012 16:19:27 GMT
Author: mduerig
Date: Fri Aug 17 16:19:26 2012
New Revision: 1374342

URL: http://svn.apache.org/viewvc?rev=1374342&view=rev
Log:
OAK-251  CommitEditor is global to ContentRepository instance
pass commit editor to NodeStoreBranch.merge() instead of NodeStore.branch()

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/KernelNodeStore.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/spi/state/NodeStore.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/KernelNodeStoreTest.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=1374342&r1=1374341&r2=1374342&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
Fri Aug 17 16:19:26 2012
@@ -38,8 +38,8 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.security.authorization.CompiledPermissions;
 import org.apache.jackrabbit.oak.spi.security.user.UserManagerConfig;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
@@ -157,7 +157,7 @@ public class RootImpl implements Root {
 
     @Override
     public final void refresh() {
-        branch = store.branch(commitEditor);
+        branch = store.branch();
         rootTree = TreeImpl.createRoot(this);
         permissions = this.accessControlContext.getPermissions();
     }
@@ -166,7 +166,7 @@ public class RootImpl implements Root {
     public void commit(ConflictHandler conflictHandler) throws CommitFailedException {
         rebase(conflictHandler);
         purgePendingChanges();
-        branch.merge();
+        branch.merge(commitEditor);
         refresh();
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1374342&r1=1374341&r2=1374342&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Fri Aug 17 16:19:26 2012
@@ -25,8 +25,8 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.EmptyEditor;
 import org.apache.jackrabbit.oak.spi.commit.EmptyObserver;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 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;
 
@@ -97,8 +97,8 @@ public class KernelNodeStore implements 
     }
 
     @Override
-    public NodeStoreBranch branch(CommitEditor commitEditor) {
-        return new KernelNodeStoreBranch(this, commitEditor);
+    public NodeStoreBranch branch() {
+        return new KernelNodeStoreBranch(this);
     }
 
     @Override

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=1374342&r1=1374341&r2=1374342&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
Fri Aug 17 16:19:26 2012
@@ -38,9 +38,6 @@ class KernelNodeStoreBranch implements N
     /** The underlying store to which this branch belongs */
     private final KernelNodeStore store;
 
-    /** The commit editor */
-    private final CommitEditor editor;
-
     /** Base state of this branch */
     private final NodeState base;
 
@@ -53,14 +50,8 @@ class KernelNodeStoreBranch implements N
     /** Last state which was committed to this branch */
     private NodeState committed;
 
-    KernelNodeStoreBranch(KernelNodeStore store, CommitEditor editor) {
+    KernelNodeStoreBranch(KernelNodeStore store) {
         this.store = store;
-        if (editor == null) {
-            this.editor = store.getEditor();
-        } else {
-            this.editor = new CompositeEditor(store.getEditor(), editor);
-        }
-
         MicroKernel kernel = store.getKernel();
         this.branchRevision = kernel.branch(null);
         this.currentRoot = new KernelNodeState(kernel, "/", branchRevision);
@@ -129,9 +120,12 @@ class KernelNodeStoreBranch implements N
     }
 
     @Override
-    public KernelNodeState merge() throws CommitFailedException {
+    public KernelNodeState merge(CommitEditor editor) throws CommitFailedException {
         NodeState oldRoot = base;
-        NodeState toCommit = editor.editCommit(store, oldRoot, currentRoot);
+        CommitEditor commitEditor = editor == null
+                ? store.getEditor()
+                : new CompositeEditor(store.getEditor(), editor);
+        NodeState toCommit = commitEditor.editCommit(store, oldRoot, currentRoot);
         setRoot(toCommit);
 
         try {

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=1374342&r1=1374341&r2=1374342&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
Fri Aug 17 16:19:26 2012
@@ -21,9 +21,8 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
-import org.apache.jackrabbit.oak.spi.commit.EmptyEditor;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 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;
 
@@ -47,7 +46,7 @@ public class MemoryNodeStore implements 
     }
 
     @Override
-    public NodeStoreBranch branch(CommitEditor editor) {
+    public NodeStoreBranch branch() {
         return new MemoryNodeStoreBranch(root.get());
     }
 
@@ -83,7 +82,7 @@ public class MemoryNodeStore implements 
         }
 
         @Override
-        public NodeState merge() throws CommitFailedException {
+        public NodeState merge(CommitEditor editor) throws CommitFailedException {
             while (!MemoryNodeStore.this.root.compareAndSet(base, root)) {
                 // TODO: rebase();
                 throw new UnsupportedOperationException();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java?rev=1374342&r1=1374341&r2=1374342&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
Fri Aug 17 16:19:26 2012
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.spi.st
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
 
 /**
  * Storage abstraction for trees. At any given point in time the stored
@@ -45,7 +44,7 @@ public interface NodeStore {
      * @return branch
      */
     @Nonnull
-    NodeStoreBranch branch(CommitEditor commitEditor);
+    NodeStoreBranch branch();
 
     /**
      * Returns a builder for constructing a new or modified node state.

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=1374342&r1=1374341&r2=1374342&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
Fri Aug 17 16:19:26 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.spi.st
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
 
 public interface NodeStoreBranch {
 
@@ -65,12 +66,13 @@ public interface NodeStoreBranch {
 
     /**
      * Merges the changes in this branch to the main content tree.
+     * @param editor  commit editor to apply
      * @return the node state resulting from the merge.
      *
      * @throws CommitFailedException if the merge failed
      */
     @Nonnull
-    NodeState merge() throws CommitFailedException;
+    NodeState merge(CommitEditor editor) throws CommitFailedException;
 
 }
 

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=1374342&r1=1374341&r2=1374342&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
Fri Aug 17 16:19:26 2012
@@ -26,8 +26,8 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
 import org.apache.jackrabbit.oak.spi.commit.EmptyEditor;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 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.Before;
@@ -70,7 +70,7 @@ public class KernelNodeStoreTest {
 
     @Test
     public void branch() throws CommitFailedException {
-        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
+        NodeStoreBranch branch = store.branch();
 
         NodeBuilder rootBuilder = store.getBuilder(branch.getRoot());
         NodeBuilder testBuilder = rootBuilder.getChildBuilder("test");
@@ -105,7 +105,7 @@ public class KernelNodeStoreTest {
         assertNull(testState.getChildNode("newNode"));
         assertNotNull(testState.getChildNode("x"));
 
-        branch.merge();
+        branch.merge(EmptyEditor.INSTANCE);
 
         // Assert changes are present in the trunk
         testState = store.getRoot().getChildNode("test");
@@ -138,9 +138,9 @@ public class KernelNodeStoreTest {
 
         NodeState newRoot = rootBuilder.getNodeState();
 
-        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
+        NodeStoreBranch branch = store.branch();
         branch.setRoot(newRoot);
-        branch.merge();
+        branch.merge(EmptyEditor.INSTANCE);
         store.getRoot(); // triggers the observer
 
         NodeState before = states[0];
@@ -181,9 +181,9 @@ public class KernelNodeStoreTest {
 
         NodeState newRoot = rootBuilder.getNodeState();
 
-        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
+        NodeStoreBranch branch = store.branch();
         branch.setRoot(newRoot);
-        branch.merge();
+        branch.merge(EmptyEditor.INSTANCE);
 
         NodeState test = store.getRoot().getChildNode("test");
         assertNotNull(test.getChildNode("newNode"));



Mime
View raw message