You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2013/12/02 18:18:43 UTC
svn commit: r1547113 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment:
SegmentNodeStore.java SegmentNodeStoreBranch.java SegmentRootState.java
Author: jukka
Date: Mon Dec 2 17:18:43 2013
New Revision: 1547113
URL: http://svn.apache.org/r1547113
Log:
OAK-1249: Fine-grained locking in SegmentMK commits
Avoid the need for extra rebasing by explicitly tracking the super-root base state.
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootState.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.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/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1547113&r1=1547112&r2=1547113&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java Mon Dec 2 17:18:43 2013
@@ -139,19 +139,21 @@ public class SegmentNodeStore implements
@Override @Nonnull
public NodeState getRoot() {
refreshHead(false);
- return head.getChildNode(ROOT);
+ return new SegmentRootState(head);
}
@Override
public NodeState merge(
@Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook,
@Nullable CommitInfo info) throws CommitFailedException {
- checkArgument(builder instanceof SegmentNodeBuilder);
checkNotNull(commitHook);
- SegmentNodeState base = head;
- rebase(builder, base.getChildNode(ROOT)); // TODO: can we avoid this?
+
+ NodeState base = builder.getBaseState();
+ checkArgument(store.isInstance(base, SegmentRootState.class));
+ SegmentNodeState root = ((SegmentRootState) base).getRootState();
+
SegmentNodeStoreBranch branch = new SegmentNodeStoreBranch(
- this, store.getWriter(), base, maximumBackoff);
+ this, store.getWriter(), root, maximumBackoff);
branch.setRoot(builder.getNodeState());
NodeState merged = branch.merge(commitHook, info);
((SegmentNodeBuilder) builder).reset(merged);
@@ -164,7 +166,7 @@ public class SegmentNodeStore implements
}
private NodeState rebase(@Nonnull NodeBuilder builder, NodeState newBase) {
- checkArgument(builder instanceof SegmentNodeBuilder);
+ checkArgument(builder instanceof SegmentRootBuilder);
NodeState oldBase = builder.getBaseState();
if (!fastEquals(oldBase, newBase)) {
NodeState head = builder.getNodeState();
@@ -185,7 +187,7 @@ public class SegmentNodeStore implements
@Override @Nonnull
public NodeState reset(@Nonnull NodeBuilder builder) {
- checkArgument(builder instanceof SegmentNodeBuilder);
+ checkArgument(builder instanceof SegmentRootBuilder);
NodeState state = getRoot();
((SegmentNodeBuilder) builder).reset(state);
return state;
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=1547113&r1=1547112&r2=1547113&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 Dec 2 17:18:43 2013
@@ -67,7 +67,7 @@ class SegmentNodeStoreBranch implements
@Override @Nonnull
public synchronized NodeState getHead() {
- return head.getChildNode(ROOT);
+ return new SegmentRootState(head);
}
@Override
Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootState.java?rev=1547113&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootState.java Mon Dec 2 17:18:43 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.segment;
+
+class SegmentRootState extends SegmentNodeState {
+
+ private final SegmentNodeState root;
+
+ SegmentRootState(SegmentNodeState root) {
+ super(root.getSegment(),
+ ((SegmentNodeState) root.getChildNode("root")).getRecordId());
+ this.root = root;
+ }
+
+ SegmentNodeState getRootState() {
+ return root;
+ }
+
+}