jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1444976 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins: commit/MergingNodeStateDiff.java segment/SegmentNodeStoreBranch.java
Date Mon, 11 Feb 2013 21:49:16 GMT
Author: jukka
Date: Mon Feb 11 21:49:15 2013
New Revision: 1444976

URL: http://svn.apache.org/r1444976
Log:
OAK-593: Segment-based MK

Improved rebase/merge behavior

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java?rev=1444976&r1=1444975&r2=1444976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
Mon Feb 11 21:49:15 2013
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 /**
  * MergingNodeStateDiff... TODO
  */
-final class MergingNodeStateDiff extends DefaultNodeStateDiff {
+public final class MergingNodeStateDiff extends DefaultNodeStateDiff {
     private static final Logger LOG = LoggerFactory.getLogger(MergingNodeStateDiff.class);
 
     public static final String CONFLICT = ":conflict";

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=1444976&r1=1444975&r2=1444976&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
Mon Feb 11 21:49:15 2013
@@ -16,11 +16,23 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.ADD_EXISTING_NODE;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.ADD_EXISTING_PROPERTY;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.CHANGE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.CHANGE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.CHANGE_DELETED_PROPERTY;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.CONFLICT;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.DELETE_CHANGED_NODE;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.DELETE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.DELETE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff.DELETE_DELETED_PROPERTY;
+
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -83,7 +95,7 @@ class SegmentNodeStoreBranch implements 
             if (other == null) {
                 builder.setProperty(after);
             } else if (!other.equals(after)) {
-                conflictMarker("addExistingProperty").setProperty(after);
+                conflictMarker(ADD_EXISTING_PROPERTY).setProperty(after);
             }
         }
 
@@ -91,11 +103,11 @@ class SegmentNodeStoreBranch implements 
         public void propertyChanged(PropertyState before, PropertyState after) {
             PropertyState other = builder.getProperty(before.getName());
             if (other == null) {
-                conflictMarker("changeDeletedProperty").setProperty(after);
+                conflictMarker(CHANGE_DELETED_PROPERTY).setProperty(after);
             } else if (other.equals(before)) {
                 builder.setProperty(after);
             } else if (!other.equals(after)) {
-                conflictMarker("changeChangedProperty").setProperty(after);
+                conflictMarker(CHANGE_CHANGED_PROPERTY).setProperty(after);
             }
         }
 
@@ -103,18 +115,18 @@ class SegmentNodeStoreBranch implements 
         public void propertyDeleted(PropertyState before) {
             PropertyState other = builder.getProperty(before.getName());
             if (other == null) {
-                conflictMarker("deleteDeletedProperty").setProperty(before);
+                conflictMarker(DELETE_DELETED_PROPERTY).setProperty(before);
             } else if (other.equals(before)) {
                 builder.removeProperty(before.getName());
             } else {
-                conflictMarker("deleteChangedProperty").setProperty(before);
+                conflictMarker(DELETE_CHANGED_PROPERTY).setProperty(before);
             }
         }
 
         @Override
         public void childNodeAdded(String name, NodeState after) {
             if (builder.hasChildNode(name)) {
-                conflictMarker("addExistingNode").setNode(name, after);
+                conflictMarker(ADD_EXISTING_NODE).setNode(name, after);
             } else {
                 builder.setNode(name, after);
             }
@@ -127,23 +139,23 @@ class SegmentNodeStoreBranch implements 
                 after.compareAgainstBaseState(
                         before, new RebaseDiff(builder.child(name)));
             } else {
-                conflictMarker("changeDeletedNode").setNode(name, after);
+                conflictMarker(CHANGE_DELETED_NODE).setNode(name, after);
             }
         }
 
         @Override
         public void childNodeDeleted(String name, NodeState before) {
             if (!builder.hasChildNode(name)) {
-                conflictMarker("deleteDeletedNode").setNode(name, before);
+                conflictMarker(DELETE_DELETED_NODE).setNode(name, before);
             } else if (before.equals(builder.child(name).getNodeState())) {
                 builder.removeNode(name);
             } else {
-                conflictMarker("deleteChangedNode").setNode(name, before);
+                conflictMarker(DELETE_CHANGED_NODE).setNode(name, before);
             }
         }
 
         private NodeBuilder conflictMarker(String name) {
-            return builder.child(":conflict").child(name);
+            return builder.child(CONFLICT).child(name);
         }
 
     }
@@ -151,12 +163,14 @@ class SegmentNodeStoreBranch implements 
     @Override
     public synchronized void rebase() {
         RecordId newBaseId = store.getJournalHead();
-        NodeBuilder builder =
-                new MemoryNodeBuilder(new SegmentNodeState(reader, newBaseId));
-        getRoot().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
-        this.baseId = newBaseId;
-        this.rootId = writer.writeNode(builder.getNodeState());
-        writer.flush();
+        if (!baseId.equals(newBaseId)) {
+            NodeBuilder builder =
+                    new MemoryNodeBuilder(new SegmentNodeState(reader, newBaseId));
+            getRoot().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
+            this.baseId = newBaseId;
+            this.rootId = writer.writeNode(builder.getNodeState());
+            writer.flush();
+        }
     }
 
     @Override @Nonnull
@@ -164,19 +178,17 @@ class SegmentNodeStoreBranch implements 
         RecordId originalBaseId = baseId;
         RecordId originalRootId = rootId;
         for (int i = 0; i < 10; i++) {
-            if (i > 0) {
-                baseId = originalBaseId;
-                rootId = originalRootId;
-                rebase();
-            }
+            rebase();
             RecordId headId =
                     writer.writeNode(hook.processCommit(getBase(), getRoot()));
             writer.flush();
-            if (store.setJournalHead(rootId, baseId)) {
+            if (store.setJournalHead(headId, baseId)) {
                 baseId = headId;
                 rootId = headId;
                 return getRoot();
             }
+            baseId = originalBaseId;
+            rootId = originalRootId;
         }
         throw new CommitFailedException();
     }



Mime
View raw message