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 mr...@apache.org on 2013/03/20 12:46:28 UTC
svn commit: r1458775 - in
/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype:
Commit.java UpdateOp.java
Author: mreutegg
Date: Wed Mar 20 11:46:28 2013
New Revision: 1458775
URL: http://svn.apache.org/r1458775
Log:
OAK-619 Lock-free MongoMK implementation
- annotate nodes with reference to commit root
Modified:
jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/UpdateOp.java
Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java?rev=1458775&r1=1458774&r2=1458775&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/Commit.java Wed Mar 20 11:46:28 2013
@@ -118,8 +118,6 @@ public class Commit {
/**
* Apply the changes to the document store (to update MongoDB).
- *
- * @param store the store
*/
void applyToDocumentStore() {
DocumentStore store = mk.getDocumentStore();
@@ -139,6 +137,7 @@ public class Commit {
}
}
}
+ int commitRootDepth = PathUtils.getDepth(commitRoot);
// create a "root of the commit" if there is none
UpdateOp root = getUpdateOperationForNode(commitRoot);
for (String p : operations.keySet()) {
@@ -152,12 +151,20 @@ public class Commit {
}
}
if (changedNodes.size() == 0 && root.isNew) {
- // no updates, so we just add the root like the others
+ // no updates and root of commit is also new. that is,
+ // it is the root of a subtree added in a commit.
+ // so we just add the root like the others
+ root.addMapEntry(UpdateOp.REVISIONS + "." + revision.toString(), "true");
newNodes.add(root);
- root = null;
}
try {
if (newNodes.size() > 0) {
+ // set commit root on new nodes
+ for (UpdateOp op : newNodes) {
+ if (op != root) {
+ op.addMapEntry(UpdateOp.COMMIT_ROOT + "." + revision.toString(), commitRootDepth);
+ }
+ }
if (!store.create(Collection.NODES, newNodes)) {
for (UpdateOp op : newNodes) {
op.unset(UpdateOp.ID);
@@ -168,9 +175,13 @@ public class Commit {
}
}
for (UpdateOp op : changedNodes) {
+ // set commit root on changed nodes
+ op.addMapEntry(UpdateOp.COMMIT_ROOT + "." + revision.toString(), commitRootDepth);
createOrUpdateNode(store, op);
}
- if (root != null) {
+ // finally write commit, unless it was already written
+ // with added nodes.
+ if (changedNodes.size() != 0 || !root.isNew) {
long increment = mk.getWriteCountIncrement(commitRoot);
root.increment(UpdateOp.WRITE_COUNT, 1 + increment);
root.addMapEntry(UpdateOp.REVISIONS + "." + revision.toString(), "true");
Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/UpdateOp.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/UpdateOp.java?rev=1458775&r1=1458774&r2=1458775&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/UpdateOp.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/UpdateOp.java Wed Mar 20 11:46:28 2013
@@ -40,7 +40,13 @@ public class UpdateOp {
* root of the commit.
*/
static final String REVISIONS = "_revisions";
-
+
+ /**
+ * The list of revision to root commit depth mappings to find out if a
+ * revision is actually committed.
+ */
+ static final String COMMIT_ROOT = "_commitRoot";
+
/**
* The number of previous documents (documents that contain old revisions of
* this node). This property is only set if multiple documents per node
@@ -71,8 +77,6 @@ public class UpdateOp {
* @param path the node path (for nodes)
* @param key the primary key
* @param isNew whether this is a new document
- * @param isDelete whether the _deleted property is set
- * @param rev the revision
*/
UpdateOp(String path, String key, boolean isNew) {
this.path = path;
@@ -143,7 +147,7 @@ public class UpdateOp {
/**
* Increment the value.
*
- * @param key the key
+ * @param property the key
* @param value the increment
*/
void increment(String property, long value) {