jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1437278 - in /jackrabbit/oak/trunk/oak-mongomk: ./ src/main/java/org/apache/jackrabbit/mongomk/impl/action/ src/main/java/org/apache/jackrabbit/mongomk/impl/command/ src/test/java/org/apache/jackrabbit/mongomk/impl/
Date Wed, 23 Jan 2013 07:31:59 GMT
Author: meteatamel
Date: Wed Jan 23 07:31:59 2013
New Revision: 1437278

URL: http://svn.apache.org/viewvc?rev=1437278&view=rev
Log:
OAK-571 - Limit usage of headRevId in sync collection to non-branches 

Now headRevId in sync collection is only updated for trunk commits. Also updated the mongo
java driver version.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/pom.xml
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommandNew.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKBranchMergeTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/pom.xml?rev=1437278&r1=1437277&r2=1437278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk/pom.xml Wed Jan 23 07:31:59 2013
@@ -87,7 +87,7 @@
     <dependency>
       <groupId>org.mongodb</groupId>
       <artifactId>mongo-java-driver</artifactId>
-      <version>2.9.1</version>
+      <version>2.10.1</version>
     </dependency>
 
     <!-- Logging -->

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java?rev=1437278&r1=1437277&r2=1437278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
Wed Jan 23 07:31:59 2013
@@ -16,12 +16,9 @@
  */
 package org.apache.jackrabbit.mongomk.impl.action;
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
 import org.apache.jackrabbit.mongomk.impl.model.MongoCommit;
@@ -137,38 +134,17 @@ public class FetchCommitsAction extends 
     }
 
     private List<MongoCommit> convertToCommits(DBCursor dbCursor) {
-        Map<Long, MongoCommit> commits = new HashMap<Long, MongoCommit>();
-        while (dbCursor.hasNext()) {
-            MongoCommit commitMongo = (MongoCommit) dbCursor.next();
-            commits.put(commitMongo.getRevisionId(), commitMongo);
-        }
-        dbCursor.close();
-
-        List<MongoCommit> validCommits = new LinkedList<MongoCommit>();
-        if (commits.isEmpty()) {
-            return validCommits;
-        }
-
-        Set<Long> revisions = commits.keySet();
-        long currentRevision = (toRevisionId != -1 && revisions.contains(toRevisionId))
?
-                toRevisionId : Collections.max(revisions);
-
-        while (true) {
-            MongoCommit commitMongo = commits.get(currentRevision);
-            if (commitMongo == null) {
-                break;
+        try {
+            List<MongoCommit> commits = new ArrayList<MongoCommit>();
+            while (dbCursor.hasNext()) {
+                commits.add((MongoCommit) dbCursor.next());
             }
-            validCommits.add(commitMongo);
-            long baseRevision = commitMongo.getBaseRevisionId();
-            if (currentRevision == 0L || baseRevision < fromRevisionId) {
-                break;
-            }
-            currentRevision = baseRevision;
-        }
+            LOG.debug("Found list of valid revisions for max revision {}: {}",
+                    toRevisionId, commits);
 
-        LOG.debug("Found list of valid revisions for max revision {}: {}",
-                toRevisionId, validCommits);
-
-        return validCommits;
+            return commits;
+        } finally {
+            dbCursor.close();
+        }
     }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java?rev=1437278&r1=1437277&r2=1437278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
Wed Jan 23 07:31:59 2013
@@ -171,7 +171,8 @@ public class CommitCommand extends BaseC
 
     private void prepareCommit() throws Exception {
         commit.setAffectedPaths(affectedPaths);
-        commit.setBaseRevisionId(mongoSync.getHeadRevisionId());
+        commit.setBaseRevisionId(branchId == null?
+                mongoSync.getHeadRevisionId() : baseRevisionId);
         commit.setRevisionId(revisionId);
         if (commit.getBranchId() == null && branchId != null) {
             commit.setBranchId(branchId);
@@ -181,7 +182,7 @@ public class CommitCommand extends BaseC
 
     private void readExistingNodes() {
         FetchNodesAction action = new FetchNodesAction(nodeStore, affectedPaths,
-                mongoSync.getHeadRevisionId());
+                branchId == null? mongoSync.getHeadRevisionId() : baseRevisionId);
         action.setBranchId(branchId);
         action.setValidCommits(validCommits);
         existingNodes = action.execute();
@@ -282,6 +283,11 @@ public class CommitCommand extends BaseC
      * @throws Exception If an exception happens.
      */
     protected boolean saveAndSetHeadRevision() throws Exception {
+        // Don't update the head revision id for branches.
+        if (branchId != null) {
+            return true;
+        }
+
         long assumedHeadRevision = this.mongoSync.getHeadRevisionId();
         MongoSync mongoSync = new SaveAndSetHeadRevisionAction(nodeStore,
                 assumedHeadRevision, revisionId).execute();

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommandNew.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommandNew.java?rev=1437278&r1=1437277&r2=1437278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommandNew.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommandNew.java
Wed Jan 23 07:31:59 2013
@@ -169,7 +169,8 @@ public class CommitCommandNew extends Ba
 
     private void prepareCommit() throws Exception {
         commit.setAffectedPaths(affectedPaths);
-        commit.setBaseRevisionId(mongoSync.getHeadRevisionId());
+        commit.setBaseRevisionId(branchId == null?
+                mongoSync.getHeadRevisionId() : baseRevisionId);
         commit.setRevisionId(revisionId);
         if (commit.getBranchId() == null && branchId != null) {
             commit.setBranchId(branchId);
@@ -192,9 +193,13 @@ public class CommitCommandNew extends Ba
 
         existingNodes = new HashMap<String, MongoNode>();
         for (String path : affectedPaths) {
-            NodeExistsCommand command = new NodeExistsCommand(
-                    nodeStore, path, mongoSync.getHeadRevisionId());
-            command.setBranchId(branchId);
+            NodeExistsCommand command;
+            if (branchId == null) {
+                command = new NodeExistsCommand(nodeStore, path, mongoSync.getHeadRevisionId());
+            } else {
+                command = new NodeExistsCommand(nodeStore, path, baseRevisionId);
+                command.setBranchId(branchId);
+            }
             if (command.execute()) {
                 existingNodes.put(path, command.getNode());
             }
@@ -298,6 +303,11 @@ public class CommitCommandNew extends Ba
      * @throws Exception If an exception happens.
      */
     protected boolean saveAndSetHeadRevision() throws Exception {
+        // Don't update the head revision id for branches.
+        if (branchId != null) {
+            return true;
+        }
+
         long assumedHeadRevision = this.mongoSync.getHeadRevisionId();
         MongoSync mongoSync = new SaveAndSetHeadRevisionAction(nodeStore,
                 assumedHeadRevision, revisionId).execute();

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKBranchMergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKBranchMergeTest.java?rev=1437278&r1=1437277&r2=1437278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKBranchMergeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKBranchMergeTest.java
Wed Jan 23 07:31:59 2013
@@ -344,7 +344,6 @@ public class MongoMKBranchMergeTest exte
     }
 
     @Test
-    @Ignore("OAK-560")
     public void concurrentNonConflictingMerges() throws Exception {
         int numThreads = 10;
         mk.commit("/", "+\"test\":{}", null, null);



Mime
View raw message