jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1407119 [2/9] - in /jackrabbit/oak/trunk: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/ oak-mk-perf/ oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/tasks/ oak-...
Date Thu, 08 Nov 2012 15:18:02 GMT
Added: jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java?rev=1407119&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java (added)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java Thu Nov  8 15:17:50 2012
@@ -0,0 +1,73 @@
+/*
+ * 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.mk.util;
+
+
+
+/**
+ * Useful methods for building node structure.
+ * 
+ * 
+ */
+public class MicroKernelOperation {
+
+    /**
+     * Builds a diff representing a pyramid node structure.
+     * 
+     * @param The
+     *            path where the first node will be added.
+     * @param index
+     * @param numberOfChildren
+     *            The number of children that each node must have.
+     * @param nodesNumber
+     *            Total number of nodes.
+     * @param nodePrefixName
+     *            The node name prefix.
+     * @param diff
+     *            The string where the diff is builded.Put an empty string for
+     *            creating a new structure.
+     * @return
+     */
+    public static StringBuilder buildPyramidDiff(String startingPoint,
+            int index, int numberOfChildren, long nodesNumber,
+            String nodePrefixName, StringBuilder diff) {
+        if (numberOfChildren == 0) {
+            for (long i = 0; i < nodesNumber; i++)
+                diff.append(addNodeToDiff(startingPoint, nodePrefixName + i));
+            return diff;
+        }
+        if (index >= nodesNumber)
+            return diff;
+        diff.append(addNodeToDiff(startingPoint, nodePrefixName + index));
+        //System.out.println("Create node "+ index);
+        for (int i = 1; i <= numberOfChildren; i++) {
+            if (!startingPoint.endsWith("/"))
+                startingPoint = startingPoint + "/";
+            buildPyramidDiff(startingPoint + nodePrefixName + index, index
+                    * numberOfChildren + i, numberOfChildren, nodesNumber,
+                    nodePrefixName, diff);
+        }
+        return diff;
+    }
+
+    private static String addNodeToDiff(String startingPoint, String nodeName) {
+        if (!startingPoint.endsWith("/"))
+            startingPoint = startingPoint + "/";
+
+        return ("+\"" + startingPoint + nodeName + "\" : {\"key\":\"00000000000000000000\"} \n");
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/main/java/org/apache/jackrabbit/mk/util/MicroKernelOperation.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-mk-perf/src/main/resources/config.cfg
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/main/resources/config.cfg?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/main/resources/config.cfg (original)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/main/resources/config.cfg Thu Nov  8 15:17:50 2012
@@ -1,3 +1,20 @@
+#########################################################################
+# 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.
+##########################################################################
+
 mk.type=oak
 hostname=localhost
 mongo.port=27017

Modified: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MKAddNodesRelativePathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MKAddNodesRelativePathTest.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MKAddNodesRelativePathTest.java (original)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MKAddNodesRelativePathTest.java Thu Nov  8 15:17:50 2012
@@ -16,59 +16,50 @@
  */
 package org.apache.jackrabbit.mk.tests;
 
-import org.apache.jackrabbit.mk.util.MKOperation;
 import org.apache.jackrabbit.mk.testing.MicroKernelTestBase;
+import org.apache.jackrabbit.mk.util.Committer;
 import org.junit.Test;
 
 /**
  * Measure the time needed for writing nodes in different tree structures.Each
- * node is committed separately.Each node is also committed using the relative path of
- * the parent node.
- * 
- * @author rogoz
- * 
+ * node is committed separately.Each node is also committed using the relative
+ * path of the parent node.
  */
-
 public class MKAddNodesRelativePathTest extends MicroKernelTestBase {
 
-	static String nodeNamePrefix = "N";
-	static int nodesNumber = 1000;
+    static String nodeNamePrefix = "N";
+    static int nodesNumber = 1000;
 
-	/**
-	 * Writes all the nodes on the same level.All the nodes have the same
-	 * parent.
-	 * 
-	 * @throws Exception
-	 */
-
-	@Test
-	public void testWriteNodesSameLevel() throws Exception {
-
-		chronometer.start();
-		MKOperation.addPyramidStructure(mk, "/", 0, 0, nodesNumber,
-				nodeNamePrefix);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodesSameLevel is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes10Children() {
-		chronometer.start();
-		MKOperation.addPyramidStructure(mk, "/", 0, 10, nodesNumber,
-				nodeNamePrefix);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes10Children is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes100Children() {
-		chronometer.start();
-		MKOperation.addPyramidStructure(mk, "/", 0, 100, nodesNumber,
-				nodeNamePrefix);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes100Children is "
-				+ chronometer.getSeconds());
-	}
+    @Test
+    public void testWriteNodesSameLevel() throws Exception {
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addPyramidStructure(mk, "/", 0, 0, nodesNumber, nodeNamePrefix);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodesSameLevel is "
+                + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testWriteNodes10Children() {
+        Committer commiter = new Committer();
+        chronometer.start();
+
+        commiter.addPyramidStructure(mk, "/", 0, 10, nodesNumber,
+                nodeNamePrefix);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes10Children is "
+                + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testWriteNodes100Children() {
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addPyramidStructure(mk, "/", 0, 100, nodesNumber,
+                nodeNamePrefix);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes100Children is "
+                + chronometer.getSeconds());
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesDifferentStructuresTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesDifferentStructuresTest.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesDifferentStructuresTest.java (original)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesDifferentStructuresTest.java Thu Nov  8 15:17:50 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.mk.tests;
 
-import org.apache.jackrabbit.mk.util.MKOperation;
+import org.apache.jackrabbit.mk.util.MicroKernelOperation;
 import org.apache.jackrabbit.mk.testing.MicroKernelTestBase;
 import org.apache.jackrabbit.mk.util.Committer;
 import org.junit.Test;
@@ -24,77 +24,115 @@ import org.junit.Test;
 /**
  * Measure the time needed for writing nodes in different tree structures.All
  * the nodes are added in a single commit.
- * 
- * @author rogoz
- * 
  */
 public class MkAddNodesDifferentStructuresTest extends MicroKernelTestBase {
 
-	static int nodesNumber = 100000;
-	static String nodeNamePrefix = "N";
+    static long nodesNumber = 100;
+    static String nodeNamePrefix = "N";
 
-	@Test
-	public void testWriteNodesSameLevel() {
-
-		String diff = MKOperation.buildPyramidDiff("/", 0, 0, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-		Committer committer = new Committer();
-		chronometer.start();
-		committer.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodesSameLevel is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes1Child() {
-		int nodesNumber = 100;
-
-		String diff = MKOperation.buildPyramidDiff("/", 0, 1, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-		Committer committer = new Committer();
-		chronometer.start();
-		committer.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes1Child is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes10Children() {
-
-		String diff = MKOperation.buildPyramidDiff("/", 0, 10, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-		Committer committer = new Committer();
-		chronometer.start();
-		committer.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes10Children is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes100Children() {
-
-		String diff = MKOperation.buildPyramidDiff("/", 0, 100, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-		Committer committer = new Committer();
-		chronometer.start();
-		committer.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes100Children is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes1000Children() {
-		String diff = MKOperation.buildPyramidDiff("/", 0, 1000, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-		Committer committer = new Committer();
-		chronometer.start();
-		committer.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes1000Children is "
-				+ chronometer.getSeconds());
-	}
+    /**
+     * Tree structure:
+     * <p>
+     * rootNode (/)
+     * <p>
+     * N0 N1... Nn-1 Nn
+     */
+    @Test
+    public void testWriteNodesSameLevel() {
+
+        String diff = MicroKernelOperation.buildPyramidDiff("/", 0, 0,
+                nodesNumber, nodeNamePrefix, new StringBuilder()).toString();
+        Committer committer = new Committer();
+        chronometer.start();
+        committer.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodesSameLevel is "
+                + chronometer.getSeconds());
+    }
+
+    /**
+     * Tree structure:
+     * <p>
+     * rootNode (/)
+     * <p>
+     * N0
+     * <p>
+     * N1
+     * <p>
+     * N2
+     * <p>
+     * N3
+     */
+    @Test
+    public void testWriteNodes1Child() {
+        int nodesNumber = 100;
+
+        String diff = MicroKernelOperation.buildPyramidDiff("/", 0, 1,
+                nodesNumber, nodeNamePrefix, new StringBuilder()).toString();
+        Committer committer = new Committer();
+        chronometer.start();
+        committer.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes1Child is "
+                + chronometer.getSeconds());
+    }
+
+    /**
+     * Tree structure:
+     * <p>
+     * Number of nodes per <b>level</b> =10^(<b>level</b>).
+     * <p>
+     * Each node has 10 children.
+     */
+    @Test
+    public void testWriteNodes10Children() {
+
+        String diff = MicroKernelOperation.buildPyramidDiff("/", 0, 10,
+                nodesNumber, nodeNamePrefix, new StringBuilder()).toString();
+        Committer committer = new Committer();
+        chronometer.start();
+        committer.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes10Children is "
+                + chronometer.getSeconds());
+    }
+
+    /**
+     * Tree structure:
+     * <p>
+     * Number of nodes per <b>level</b> =100^(<b>level</b>).
+     * <p>
+     * Each node has 100 children.
+     */
+    @Test
+    public void testWriteNodes100Children() {
+
+        String diff = MicroKernelOperation.buildPyramidDiff("/", 0, 100,
+                nodesNumber, nodeNamePrefix, new StringBuilder()).toString();
+        Committer committer = new Committer();
+        chronometer.start();
+        committer.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes100Children is "
+                + chronometer.getSeconds());
+    }
+
+    /**
+     * Tree structure:
+     * <p>
+     * Number of nodes per <b>level</b> =1000^(<b>level</b>).
+     * <p>
+     * Each node has 1000 children.
+     */
+    @Test
+    public void testWriteNodes1000Children() {
+        String diff = MicroKernelOperation.buildPyramidDiff("/", 0, 1000,
+                nodesNumber, nodeNamePrefix, new StringBuilder()).toString();
+        Committer committer = new Committer();
+        chronometer.start();
+        committer.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes1000Children is "
+                + chronometer.getSeconds());
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesMultipleCommitsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesMultipleCommitsTest.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesMultipleCommitsTest.java (original)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkAddNodesMultipleCommitsTest.java Thu Nov  8 15:17:50 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.mk.tests;
 
-import org.apache.jackrabbit.mk.util.MKOperation;
+import org.apache.jackrabbit.mk.util.MicroKernelOperation;
 import org.apache.jackrabbit.mk.testing.MicroKernelTestBase;
 import org.apache.jackrabbit.mk.util.Committer;
 import org.junit.BeforeClass;
@@ -24,66 +24,68 @@ import org.junit.Test;
 
 /**
  * Measure the time needed for writing the same node structure in one or
- * multiple commit steps .
- * 
- * @author rogoz
- * 
+ * multiple commit steps.
+ * <p>
+ * Tree structure:
+ * <p>
+ * Number of nodes per <b>level</b> =100^(<b>level</b>).
+ * <p>
+ * Each node has 100 children.
  */
 public class MkAddNodesMultipleCommitsTest extends MicroKernelTestBase {
 
-	static String diff;
-	static int nodesNumber = 10000;
-	static String nodeNamePrefix = "N";
-
-	@BeforeClass
-	public static void prepareDiff() {
-		diff = MKOperation.buildPyramidDiff("/", 0, 100, nodesNumber,
-				nodeNamePrefix, new StringBuilder()).toString();
-	}
-
-	@Test
-	public void testWriteNodesAllNodes1Commit() {
-
-		Committer commiter = new Committer();
-		chronometer.start();
-		commiter.addNodes(mk, diff, 0);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodesAllNodes1Commit is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes1NodePerCommit() {
-
-		Committer commiter = new Committer();
-		chronometer.start();
-		commiter.addNodes(mk, diff, 1);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes1NodePerCommit is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes50NodesPerCommit() {
-
-		Committer commiter = new Committer();
-		chronometer.start();
-		commiter.addNodes(mk, diff, 50);
-		chronometer.stop();
-		System.out.println("Total time for testWriteNodes50NodesPerCommit is "
-				+ chronometer.getSeconds());
-	}
-
-	@Test
-	public void testWriteNodes1000NodesPerCommit() {
-
-		Committer commiter = new Committer();
-		chronometer.start();
-		commiter.addNodes(mk, diff, 1000);
-		chronometer.stop();
-		System.out
-				.println("Total time for testWriteNodes1000NodesPerCommit is "
-						+ chronometer.getSeconds());
-	}
-
-}
+    static String diff;
+    static int nodesNumber = 1000;
+    static String nodeNamePrefix = "N";
+
+    @BeforeClass
+    public static void prepareDiff() {
+        diff = MicroKernelOperation.buildPyramidDiff("/", 0, 10, nodesNumber,
+                nodeNamePrefix, new StringBuilder()).toString();
+    }
+
+    @Test
+    public void testWriteNodesAllNodes1Commit() {
+
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addNodes(mk, diff, 0);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodesAllNodes1Commit is "
+                + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testWriteNodes1NodePerCommit() {
+
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addNodes(mk, diff, 1);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes1NodePerCommit is "
+                + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testWriteNodes50NodesPerCommit() {
+
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addNodes(mk, diff, 50);
+        chronometer.stop();
+        System.out.println("Total time for testWriteNodes50NodesPerCommit is "
+                + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testWriteNodes1000NodesPerCommit() {
+
+        Committer commiter = new Committer();
+        chronometer.start();
+        commiter.addNodes(mk, diff, 10);
+        chronometer.stop();
+        System.out
+                .println("Total time for testWriteNodes1000NodesPerCommit is "
+                        + chronometer.getSeconds());
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java?rev=1407119&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java (added)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java Thu Nov  8 15:17:50 2012
@@ -0,0 +1,110 @@
+/*
+ * 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.mk.tests;
+
+import java.util.ArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.jackrabbit.mk.tasks.GenericWriteTask;
+import org.apache.jackrabbit.mk.testing.ConcurrentMicroKernelTestBase;
+import org.apache.jackrabbit.mk.util.MicroKernelOperation;
+import org.junit.Test;
+
+/**
+ * Test class for microkernel concurrent writing.All the nodes are added in a
+ * single commit.
+ */
+public class MkConcurrentAddNodes1CommitTest extends ConcurrentMicroKernelTestBase {
+
+    // nodes for each worker
+    int nodesNumber = 100;
+
+    /**
+    @Rule
+    public CatchAllExceptionsRule catchAllExceptionsRule = new CatchAllExceptionsRule();
+**/
+    @Test
+    public void testConcurentWritingFlatStructure() throws InterruptedException {
+
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, 0,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+            tasks.add(new GenericWriteTask(mks.get(i), diff, 0));
+            System.out.println("The diff size is " + diff.getBytes().length);
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time for is " + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testConcurentWritingPyramid1() throws InterruptedException {
+
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, 10,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+            tasks.add(new GenericWriteTask(mks.get(i), diff, 0));
+            System.out.println("The diff size is " + diff.getBytes().length);
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time is " + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testConcurentWritingPyramid2() throws InterruptedException {
+
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, 10,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+            tasks.add(new GenericWriteTask(mks.get(i), diff, 0));
+            System.out.println("The diff size is " + diff.getBytes().length);
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time for is " + chronometer.getSeconds());
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodes1CommitTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java?rev=1407119&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java (added)
+++ jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java Thu Nov  8 15:17:50 2012
@@ -0,0 +1,118 @@
+/*
+ * 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.mk.tests;
+
+import java.util.ArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.jackrabbit.mk.tasks.GenericWriteTask;
+import org.apache.jackrabbit.mk.testing.ConcurrentMicroKernelTestBase;
+import org.apache.jackrabbit.mk.util.MicroKernelOperation;
+import org.junit.Test;
+
+/**
+ * Test class for microkernel concurrent writing.The microkernel is adding 1000
+ * nodes per commit.
+ */
+public class MkConcurrentAddNodesMultipleCommitTest extends
+        ConcurrentMicroKernelTestBase {
+
+    // nodes for each worker
+    int nodesNumber = 100;
+    int numberOfNodesPerCommit = 10;
+
+    /**
+     * @Rule public CatchAllExceptionsRule catchAllExceptionsRule = new
+     *       CatchAllExceptionsRule();
+     */
+    @Test
+    public void testConcurentWritingFlatStructure() throws InterruptedException {
+
+        int children = 0;
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, children,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+            tasks.add(new GenericWriteTask(mks.get(i), diff,
+                    numberOfNodesPerCommit));
+            System.out.println("The diff size is " + diff.getBytes().length);
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time is " + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testConcurentWritingPyramid1() throws InterruptedException {
+        int children = 15;
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, children,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+            tasks.add(new GenericWriteTask(mks.get(i), diff,
+                    numberOfNodesPerCommit));
+            System.out.println("The diff size is " + diff.getBytes().length);
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time is " + chronometer.getSeconds());
+    }
+
+    @Test
+    public void testConcurentWritingPyramid2() throws InterruptedException {
+        int children = 2;
+        ArrayList<GenericWriteTask> tasks = new ArrayList<GenericWriteTask>();
+        String diff;
+        for (int i = 0; i < mkNumber; i++) {
+
+            diff = MicroKernelOperation.buildPyramidDiff("/", 0, children,
+                    nodesNumber, "N" + i + "N", new StringBuilder()).toString();
+
+            tasks.add(new GenericWriteTask(mks.get(i), diff,
+                    numberOfNodesPerCommit));
+
+        }
+
+        ExecutorService threadExecutor = Executors.newFixedThreadPool(mkNumber);
+        chronometer.start();
+        for (GenericWriteTask genericWriteTask : tasks) {
+            threadExecutor.execute(genericWriteTask);
+        }
+        threadExecutor.shutdown();
+        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+        chronometer.stop();
+        System.out.println("Total time for is " + chronometer.getSeconds());
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-mk-perf/src/test/java/org/apache/jackrabbit/mk/tests/MkConcurrentAddNodesMultipleCommitTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml Thu Nov  8 15:17:50 2012
@@ -27,21 +27,15 @@
     <groupId>org.apache.jackrabbit</groupId>
     <artifactId>oak-parent</artifactId>
     <version>0.6-SNAPSHOT</version>
+    <relativePath>../oak-parent/pom.xml</relativePath>
   </parent>
 
   <artifactId>oak-mongomk-perf</artifactId>
+  <name>Oak Mongo MicroKernel Performance Test</name>
 
   <dependencies>
-    <dependency>
-      <groupId>org.apache.jackrabbit</groupId>
-      <artifactId>oak-mongomk-api</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.jackrabbit</groupId>
-      <artifactId>oak-mongomk-impl</artifactId>
-      <version>${project.version}</version>
-    </dependency>
+
+    <!-- Oak MongoMK -->
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>oak-mongomk</artifactId>
@@ -66,6 +60,7 @@
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>
+
   </dependencies>
 
   <build>

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java Thu Nov  8 15:17:50 2012
@@ -18,14 +18,10 @@ package org.apache.jackrabbit.mongomk.pe
 
 import java.io.File;
 import java.io.InputStream;
+import org.apache.jackrabbit.mk.blobs.BlobStore;
 
-import org.apache.jackrabbit.mongomk.api.BlobStore;
 
-
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
-public class BlobStoreFS implements BlobStore {
+public class BlobStoreFS implements  BlobStore{
 
     private final File rootDir;
 

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/Config.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/Config.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/Config.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/Config.java Thu Nov  8 15:17:50 2012
@@ -18,9 +18,6 @@ package org.apache.jackrabbit.mongomk.pe
 
 import java.util.Properties;
 
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class Config {
 
     private static final String MASTER_HOST = "master.host";

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerf.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerf.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerf.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerf.java Thu Nov  8 15:17:50 2012
@@ -28,9 +28,6 @@ import org.apache.commons.cli.OptionBuil
 import org.apache.commons.cli.Options;
 import org.apache.log4j.PropertyConfigurator;
 
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class MicroKernelPerf {
     private static Config config;
     private static boolean masterMode;

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfClient.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfClient.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfClient.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfClient.java Thu Nov  8 15:17:50 2012
@@ -21,11 +21,11 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.jackrabbit.mongomk.MongoConnection;
-import org.apache.jackrabbit.mongomk.NodeStoreMongo;
-import org.apache.jackrabbit.mongomk.api.BlobStore;
+import org.apache.jackrabbit.mk.blobs.BlobStore;
 import org.apache.jackrabbit.mongomk.api.NodeStore;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
 import org.apache.jackrabbit.mongomk.impl.json.DefaultJsopHandler;
 import org.apache.jackrabbit.mongomk.impl.json.JsopParser;
 import org.apache.jackrabbit.mongomk.perf.RandomJsopGenerator.RandomJsop;
@@ -39,9 +39,6 @@ import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
 import com.mongodb.WriteConcern;
 
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class MicroKernelPerfClient {
 
     private static class Stats extends BasicDBObject {
@@ -67,7 +64,7 @@ public class MicroKernelPerfClient {
         }
 
         @Override
-        public void propertyAdded(String path, String key, Object value) {
+        public void propertySet(String path, String key, Object value) {
             List<String> properties = addedProperties.get(path);
             if (properties == null) {
                 properties = new LinkedList<String>();
@@ -136,8 +133,8 @@ public class MicroKernelPerfClient {
     }
 
     private void createStats(VerificationHandler handler, JSONObject result) {
-        long numOfNodes = mongoConnection.getNodeCollection().count();
-        long numOfCommits = mongoConnection.getCommitCollection().count();
+        long numOfNodes = ((MongoNodeStore)microKernel.getNodeStore()).getNodeCollection().count();
+        long numOfCommits = ((MongoNodeStore)microKernel.getNodeStore()).getCommitCollection().count();
 
         Stats commitStats = new Stats("commit", commitMonitor.getLastValue(), numOfCommits, numOfNodes,
                 handler.addedNodes.size() + handler.addedProperties.size());
@@ -150,10 +147,9 @@ public class MicroKernelPerfClient {
     }
 
     private void initMicroKernel() throws Exception {
-        NodeStore nodeStore = new NodeStoreMongo(mongoConnection);
+        NodeStore nodeStore = new MongoNodeStore(mongoConnection.getDB());
         BlobStore blobStore = new BlobStoreFS(System.getProperty("java.io.tmpdir"));
-
-        microKernel = new MongoMicroKernel(nodeStore, blobStore);
+        microKernel = new MongoMicroKernel(mongoConnection, nodeStore, blobStore);
     }
 
     private void initMongo() throws Exception {

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfMaster.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfMaster.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfMaster.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/MicroKernelPerfMaster.java Thu Nov  8 15:17:50 2012
@@ -19,15 +19,15 @@ package org.apache.jackrabbit.mongomk.pe
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.jackrabbit.mongomk.MongoConnection;
-import org.apache.jackrabbit.mongomk.NodeStoreMongo;
-import org.apache.jackrabbit.mongomk.api.BlobStore;
+import org.apache.jackrabbit.mk.blobs.BlobStore;
 import org.apache.jackrabbit.mongomk.api.NodeStore;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
 import org.apache.jackrabbit.mongomk.impl.json.DefaultJsopHandler;
 import org.apache.jackrabbit.mongomk.impl.json.JsopParser;
-import org.apache.jackrabbit.mongomk.model.CommitMongo;
-import org.apache.jackrabbit.mongomk.model.HeadMongo;
+import org.apache.jackrabbit.mongomk.impl.model.MongoCommit;
+import org.apache.jackrabbit.mongomk.impl.model.MongoSync;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.log4j.Logger;
 import org.json.JSONArray;
@@ -38,9 +38,6 @@ import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
 import com.mongodb.QueryBuilder;
 
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class MicroKernelPerfMaster {
 
     private class ContinousHandler extends DefaultJsopHandler {
@@ -65,7 +62,7 @@ public class MicroKernelPerfMaster {
         }
 
         @Override
-        public void propertyAdded(String path, String key, Object value) {
+        public void propertySet(String path, String key, Object value) {
             try {
                 if (!PathUtils.denotesRoot(key)) {
                     JSONObject element = this.getObjectByPath(path);
@@ -121,10 +118,9 @@ public class MicroKernelPerfMaster {
     }
 
     private void initMicroKernel() throws Exception {
-        NodeStore nodeStore = new NodeStoreMongo(this.mongoConnection);
+        NodeStore nodeStore = new MongoNodeStore(mongoConnection.getDB());
         BlobStore blobStore = new BlobStoreFS(System.getProperty("java.io.tmpdir"));
-
-        this.microKernel = new MongoMicroKernel(nodeStore, blobStore);
+        microKernel = new MongoMicroKernel(mongoConnection, nodeStore, blobStore);
     }
 
     private void initMongo() throws Exception {
@@ -134,9 +130,9 @@ public class MicroKernelPerfMaster {
 
     private void startVerifying() throws Exception {
         while (true) {
-            List<CommitMongo> commitMongos = this.waitForCommit();
-            for (CommitMongo commitMongo : commitMongos) {
-                if (commitMongo.hasFailed()) {
+            List<MongoCommit> commitMongos = this.waitForCommit();
+            for (MongoCommit commitMongo : commitMongos) {
+                if (commitMongo.isFailed()) {
                     LOG.info(String.format("Skipping commit %d because it failed", commitMongo.getRevisionId()));
                     this.lastRevId = commitMongo.getRevisionId();
                 } else {
@@ -150,7 +146,7 @@ public class MicroKernelPerfMaster {
         }
     }
 
-    private void verifyCommit(CommitMongo commitMongo) throws Exception {
+    private void verifyCommit(MongoCommit commitMongo) throws Exception {
         String path = commitMongo.getPath();
         String jsop = commitMongo.getDiff();
 
@@ -165,7 +161,7 @@ public class MicroKernelPerfMaster {
         LOG.info(String.format("Successfully verified commit %d", commitMongo.getRevisionId()));
     }
 
-    private void verifyCommitOrder(CommitMongo commitMongo) throws Exception {
+    private void verifyCommitOrder(MongoCommit commitMongo) throws Exception {
         long baseRevId = commitMongo.getBaseRevisionId();
         long revId = commitMongo.getRevisionId();
         if (baseRevId != this.lastCommitRevId) {
@@ -218,24 +214,24 @@ public class MicroKernelPerfMaster {
         }
     }
 
-    private List<CommitMongo> waitForCommit() {
+    private List<MongoCommit> waitForCommit() {
         // TODO Change this to MicroKernel#waitForCommit
-        List<CommitMongo> commitMongos = new LinkedList<CommitMongo>();
+        List<MongoCommit> commitMongos = new LinkedList<MongoCommit>();
         this.lastHeadRevId = 0L;
 
         while (true) {
             LOG.debug("Waiting for commit...");
 
-            DBCollection headCollection = this.mongoConnection.getHeadCollection();
-            HeadMongo headMongo = (HeadMongo) headCollection.findOne();
-            if (this.lastHeadRevId < headMongo.getHeadRevisionId()) {
-                DBCollection commitCollection = this.mongoConnection.getCommitCollection();
-                DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID).greaterThan(this.lastRevId)
-                        .and(CommitMongo.KEY_REVISION_ID).lessThanEquals(headMongo.getHeadRevisionId()).get();
-                DBObject sort = QueryBuilder.start(CommitMongo.KEY_REVISION_ID).is(1).get();
+            DBCollection headCollection = ((MongoNodeStore)microKernel.getNodeStore()).getSyncCollection();
+            MongoSync syncMongo = (MongoSync) headCollection.findOne();
+            if (this.lastHeadRevId < syncMongo.getHeadRevisionId()) {
+                DBCollection commitCollection = ((MongoNodeStore)microKernel.getNodeStore()).getCommitCollection();
+                DBObject query = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).greaterThan(this.lastRevId)
+                        .and(MongoCommit.KEY_REVISION_ID).lessThanEquals(syncMongo.getHeadRevisionId()).get();
+                DBObject sort = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).is(1).get();
                 DBCursor dbCursor = commitCollection.find(query).sort(sort);
                 while (dbCursor.hasNext()) {
-                    commitMongos.add((CommitMongo) dbCursor.next());
+                    commitMongos.add((MongoCommit) dbCursor.next());
                 }
 
                 if (commitMongos.size() > 0) {
@@ -243,7 +239,7 @@ public class MicroKernelPerfMaster {
 
                     break;
                 }
-                this.lastHeadRevId = headMongo.getHeadRevisionId();
+                this.lastHeadRevId = syncMongo.getHeadRevisionId();
             }
             try {
                 Thread.sleep(2000);

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/PrepareEnvironment.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/PrepareEnvironment.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/PrepareEnvironment.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/PrepareEnvironment.java Thu Nov  8 15:17:50 2012
@@ -16,14 +16,9 @@
  */
 package org.apache.jackrabbit.mongomk.perf;
 
-import org.apache.jackrabbit.mongomk.MongoConnection;
-import org.apache.jackrabbit.mongomk.util.MongoUtil;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.log4j.Logger;
 
-
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class PrepareEnvironment {
 
     private static final Logger LOG = Logger.getLogger(PrepareEnvironment.class);
@@ -33,18 +28,16 @@ public class PrepareEnvironment {
 
     public PrepareEnvironment(Config config) throws Exception {
         this.config = config;
-
-        this.initMongo();
+        initMongo();
     }
 
     public void start() {
         LOG.info("Preparing environment");
-
-        MongoUtil.initDatabase(this.mongoConnection);
+        //mongoConnection.initializeDB(true);
     }
 
     private void initMongo() throws Exception {
-        this.mongoConnection = new MongoConnection(this.config.getMongoHost(), this.config.getMongoPort(),
-                this.config.getMongoDatabase());
+        mongoConnection = new MongoConnection(config.getMongoHost(), config.getMongoPort(),
+                config.getMongoDatabase());
     }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java Thu Nov  8 15:17:50 2012
@@ -21,13 +21,9 @@ import java.util.UUID;
 
 import org.apache.jackrabbit.mk.json.JsopBuilder;
 import org.apache.jackrabbit.mongomk.api.model.Node;
-import org.apache.jackrabbit.mongomk.impl.builder.NodeBuilder;
+import org.apache.jackrabbit.mongomk.util.NodeBuilder;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 
-
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class RandomJsopGenerator {
 
     public static class RandomJsop {
@@ -97,7 +93,8 @@ public class RandomJsopGenerator {
         this.path = path;
         String all = String.format("{ \"%s\" : %s }", PathUtils.getName(path), json);
         Node node = NodeBuilder.build(all, path);
-        this.descendants = node.getDescendants(false).toArray(new Node[0]);
+        // FIXME - This needs to change to node.getChildNodeEntries(0, -1).
+        //this.descendants = node.getDescendants(false).toArray(new Node[0]);
         this.random = new Random();
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleMksWriteNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleMksWriteNodesTest.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleMksWriteNodesTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleMksWriteNodesTest.java Thu Nov  8 15:17:50 2012
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.mongomk.performance.write;
 
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
-import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -25,102 +24,101 @@ import org.junit.Test;
 
 /**
  * Writing tests with multiple Mks.
- * @author rogoz
- *
  */
 public class MultipleMksWriteNodesTest extends MultipleNodesTestBase {
 
-	static int mkNumber = 5;
-	static long nodesNumber=2000;
-	static SimpleWriter[] sWorker = new SimpleWriter[mkNumber];
-	static AdvanceWriter[] aWorker = new AdvanceWriter[mkNumber];
-
-	@BeforeClass
-	public static void init() throws Exception {
-		readConfig();
-		initMongo();
-		for (int i = 0; i < mkNumber; i++) {
-			MongoMicroKernel mk = initMicroKernel();
-			sWorker[i] = new SimpleWriter("Thread " + i, mk,nodesNumber);
-			aWorker[i] = new AdvanceWriter("Thread " + i, mk,nodesNumber);
-		}
-	}
-
-	@Before
-	public void cleanDatabase() {
-		MongoUtil.initDatabase(mongoConnection);
-	}
-
-	/**
-	 * Each worker creates 2000 nodes on the same level.
-	 * 5 workers x 2000 nodes=10000 nodes
-	 * @throws InterruptedException
-	 */
-	@Test
-	public void testWriteSameLine() throws InterruptedException {
-
-		for (int i = 0; i < mkNumber; i++) {
-			sWorker[i].start();
-
-		}
-		for (int i = 0; i < mkNumber; i++) {
-			sWorker[i].join();
-		}
-	}
-
-	/**
-	 * Each worker is creating a pyramid containing 2000 nodes.
-	 * 5 workers x 2000 nodes=10000 nodes
-	 * 
-	 * @throws InterruptedException
-	 */
-	@Test
-	public void testWritePyramid() throws InterruptedException {
-
-		for (int i = 0; i < mkNumber; i++) {
-			aWorker[i].start();
-
-		}
-		for (int i = 0; i < mkNumber; i++) {
-			aWorker[i].join();
-		}
-	}
+    static int mkNumber = 5;
+    static long nodesNumber=2000;
+    static SimpleWriter[] sWorker = new SimpleWriter[mkNumber];
+    static AdvanceWriter[] aWorker = new AdvanceWriter[mkNumber];
+
+    @BeforeClass
+    public static void init() throws Exception {
+        readConfig();
+        initMongo();
+        for (int i = 0; i < mkNumber; i++) {
+            MongoMicroKernel mk = initMicroKernel();
+            sWorker[i] = new SimpleWriter("Thread " + i, mk,nodesNumber);
+            aWorker[i] = new AdvanceWriter("Thread " + i, mk,nodesNumber);
+        }
+    }
+
+    @Before
+    public void cleanDatabase() {
+        // FIXME
+        //mongoConnection.initializeDB(true);
+    }
+
+    /**
+     * Each worker creates 2000 nodes on the same level.
+     * 5 workers x 2000 nodes=10000 nodes
+     * @throws InterruptedException
+     */
+    @Test
+    public void testWriteSameLine() throws InterruptedException {
+
+        for (int i = 0; i < mkNumber; i++) {
+            sWorker[i].start();
+
+        }
+        for (int i = 0; i < mkNumber; i++) {
+            sWorker[i].join();
+        }
+    }
+
+    /**
+     * Each worker is creating a pyramid containing 2000 nodes.
+     * 5 workers x 2000 nodes=10000 nodes
+     *
+     * @throws InterruptedException
+     */
+    @Test
+    public void testWritePyramid() throws InterruptedException {
+
+        for (int i = 0; i < mkNumber; i++) {
+            aWorker[i].start();
+
+        }
+        for (int i = 0; i < mkNumber; i++) {
+            aWorker[i].join();
+        }
+    }
 
 }
 
 class SimpleWriter extends Thread {
 
-	MongoMicroKernel mk;
+    MongoMicroKernel mk;
 
-	long nodesNumber;
+    long nodesNumber;
 
-	public SimpleWriter(String str, MongoMicroKernel mk, long nodesNumber) {
-		super(str);
-		this.mk = mk;
-		this.nodesNumber = nodesNumber;
-	}
-
-	public void run() {
-		for (int i = 0; i < nodesNumber; i++) {
-			TestUtil.createNode(mk, "/", getId() + "No" + i);
-		}
-	}
+    public SimpleWriter(String str, MongoMicroKernel mk, long nodesNumber) {
+        super(str);
+        this.mk = mk;
+        this.nodesNumber = nodesNumber;
+    }
+
+    public void run() {
+        for (int i = 0; i < nodesNumber; i++) {
+            TestUtil.createNode(mk, "/", getId() + "No" + i);
+        }
+    }
 }
 
 class AdvanceWriter extends Thread {
 
-	MongoMicroKernel mk;
-	long nodesNumber;
+    MongoMicroKernel mk;
+    long nodesNumber;
 
-	public AdvanceWriter(String str, MongoMicroKernel mk, long nodesNumber) {
-		super(str);
-		this.mk = mk;
-		this.nodesNumber = nodesNumber;
-	}
+    public AdvanceWriter(String str, MongoMicroKernel mk, long nodesNumber) {
+        super(str);
+        this.mk = mk;
+        this.nodesNumber = nodesNumber;
+    }
 
-	public void run() {
+    public void run() {
 
-		TestUtil.insertNode(mk, "/", 0, 50, nodesNumber, "T" + getId());
+        TestUtil.insertNode(mk, "/", 0, 50, nodesNumber, "T" + getId());
 
-	}
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleNodesTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleNodesTestBase.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleNodesTestBase.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/MultipleNodesTestBase.java Thu Nov  8 15:17:50 2012
@@ -19,41 +19,36 @@ package org.apache.jackrabbit.mongomk.pe
 import java.io.InputStream;
 import java.util.Properties;
 
-import org.apache.jackrabbit.mongomk.MongoConnection;
-import org.apache.jackrabbit.mongomk.NodeStoreMongo;
-import org.apache.jackrabbit.mongomk.api.BlobStore;
-import org.apache.jackrabbit.mongomk.api.NodeStore;
+import org.apache.jackrabbit.mk.blobs.BlobStore;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
 import org.apache.jackrabbit.mongomk.perf.BlobStoreFS;
 import org.apache.jackrabbit.mongomk.perf.Config;
 
-
-
-
 public class MultipleNodesTestBase {
 
-	
-	protected static MongoConnection mongoConnection;
-	private static Config config;
-
-	static void initMongo() throws Exception {
-		mongoConnection = new MongoConnection(config.getMongoHost(),
-				config.getMongoPort(), config.getMongoDatabase());
-	}
-
-	static MongoMicroKernel initMicroKernel() throws Exception {
-		NodeStore nodeStore = new NodeStoreMongo(mongoConnection);
-		BlobStore blobStore = new BlobStoreFS(
-				System.getProperty("java.io.tmpdir"));
-		return new MongoMicroKernel(nodeStore, blobStore);
-	}
-
-	static void readConfig() throws Exception {
-		InputStream is = MultipleNodesTestBase.class
-				.getResourceAsStream("/config.cfg");
-		Properties properties = new Properties();
-		properties.load(is);
-		is.close();
-		config = new Config(properties);
-	}
+    protected static MongoConnection mongoConnection;
+    private static Config config;
+
+    static void initMongo() throws Exception {
+        mongoConnection = new MongoConnection(config.getMongoHost(),
+                config.getMongoPort(), config.getMongoDatabase());
+    }
+
+    static MongoMicroKernel initMicroKernel() throws Exception {
+        MongoNodeStore nodeStore = new MongoNodeStore(mongoConnection.getDB());
+        BlobStore blobStore = new BlobStoreFS(
+                System.getProperty("java.io.tmpdir"));
+        return new MongoMicroKernel(mongoConnection, nodeStore, blobStore);
+    }
+
+    static void readConfig() throws Exception {
+        InputStream is = MultipleNodesTestBase.class
+                .getResourceAsStream("/config.cfg");
+        Properties properties = new Properties();
+        properties.load(is);
+        is.close();
+        config = new Config(properties);
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/WriteNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/WriteNodesTest.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/WriteNodesTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/performance/write/WriteNodesTest.java Thu Nov  8 15:17:50 2012
@@ -17,69 +17,76 @@
 package org.apache.jackrabbit.mongomk.performance.write;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mongomk.util.MongoUtil;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
+import org.apache.jackrabbit.mongomk.impl.blob.MongoBlobStore;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import com.mongodb.DB;
+
 /**
  * Measures the time needed for creating different tree node structures.Only one
  * mongoMk is used for writing operation.
- * 
- * @author rogoz
- * 
  */
 public class WriteNodesTest extends MultipleNodesTestBase {
-	static MicroKernel mk;
-	
-	@BeforeClass
-	public static void init() throws Exception {
-		readConfig();
-		initMongo();
-		mk=initMicroKernel();
-	}
-	
-	@Before
-	public void cleanDatabase() {
-		MongoUtil.initDatabase(mongoConnection);
-	}
-
-	/**
-	 * Creates 10000 nodes, all with on the same level with the same parent
-	 * node.
-	 */
-	@Test
-	public void addNodesInLine() {
-		int nodesNumber = 10000;
-		TestUtil.insertNode(mk, "/", 0, 0, nodesNumber, "N");
-	}
-
-	/**
-	 * Creates 10000 nodes, all of them having 10 children nodes.
-	 */
-	@Test
-	public void addNodes10Children() {
-		int nodesNumber = 10000;
-		TestUtil.insertNode(mk, "/", 0, 10, nodesNumber, "N");
-	}
-	
-	/**
-	 * Creates 10000 nodes, all of them having 100 children nodes.
-	 */
-	@Test
-	public void addNodes100Children() {
-		int nodesNumber = 10000;
-		TestUtil.insertNode(mk, "/", 0, 100, nodesNumber, "N");
-	}
-
-	/**
-	 * Creates 10000 nodes, all of them on different levels.Each node has one
-	 * child only.
-	 */
-	@Test
-	public void addNodes1Child() {
-		int nodesNumber = 2000;
-		TestUtil.insertNode(mk, "/", 0, 1, nodesNumber,"N");
-	}
+    static MicroKernel mk;
 
-}
+    @BeforeClass
+    public static void init() throws Exception {
+        readConfig();
+        initMongo();
+        mk = initMicroKernel();
+    }
+
+    @Before
+    public void cleanDatabase() {
+        DB db = mongoConnection.getDB();
+        dropCollections(db);
+    }
+
+    private void dropCollections(DB db) {
+        db.getCollection(MongoBlobStore.COLLECTION_BLOBS).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_COMMITS).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_NODES).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_SYNC).drop();
+    }
+
+    /**
+     * Creates 10000 nodes, all with on the same level with the same parent
+     * node.
+     */
+    @Test
+    public void addNodesInLine() {
+        int nodesNumber = 10000;
+        TestUtil.insertNode(mk, "/", 0, 0, nodesNumber, "N");
+    }
+
+    /**
+     * Creates 10000 nodes, all of them having 10 children nodes.
+     */
+    @Test
+    public void addNodes10Children() {
+        int nodesNumber = 10000;
+        TestUtil.insertNode(mk, "/", 0, 10, nodesNumber, "N");
+    }
+
+    /**
+     * Creates 10000 nodes, all of them having 100 children nodes.
+     */
+    @Test
+    public void addNodes100Children() {
+        int nodesNumber = 10000;
+        TestUtil.insertNode(mk, "/", 0, 100, nodesNumber, "N");
+    }
+
+    /**
+     * Creates 10000 nodes, all of them on different levels.Each node has one
+     * child only.
+     */
+    @Test
+    public void addNodes1Child() {
+        int nodesNumber = 2000;
+        TestUtil.insertNode(mk, "/", 0, 1, nodesNumber,"N");
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-mongomk-test/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-test/pom.xml?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-test/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk-test/pom.xml Thu Nov  8 15:17:50 2012
@@ -51,6 +51,13 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>1.0.1</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
 </project>

Modified: jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java Thu Nov  8 15:17:50 2012
@@ -20,23 +20,20 @@ import java.io.InputStream;
 import java.util.Properties;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.blobs.BlobStore;
 import org.apache.jackrabbit.mk.test.MicroKernelFixture;
-import org.apache.jackrabbit.mongomk.api.BlobStore;
-import org.apache.jackrabbit.mongomk.api.NodeStore;
-import org.apache.jackrabbit.mongomk.impl.BlobStoreMongo;
 import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
-import org.apache.jackrabbit.mongomk.impl.NodeStoreMongo;
-import org.apache.jackrabbit.mongomk.util.MongoUtil;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
+import org.apache.jackrabbit.mongomk.impl.blob.MongoBlobStore;
+import org.apache.jackrabbit.mongomk.impl.blob.MongoGridFSBlobStore;
 import org.junit.Assert;
 
+import com.mongodb.DB;
 
-/**
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
- */
 public class MongoMicroKernelFixture implements MicroKernelFixture {
 
-    private static MongoConnection mongoConnection = createMongoConnection();
+    private static MongoConnection mongoConnection;
 
     private static MongoConnection createMongoConnection() {
         try {
@@ -57,11 +54,14 @@ public class MongoMicroKernelFixture imp
     @Override
     public void setUpCluster(MicroKernel[] cluster) {
         try {
-            MongoUtil.initDatabase(mongoConnection);
-            NodeStore nodeStore = new NodeStoreMongo(mongoConnection);
-            BlobStore blobStore = new BlobStoreMongo(mongoConnection);
+            mongoConnection = createMongoConnection();
+            DB db = mongoConnection.getDB();
+            dropCollections(db);
+
+            MongoNodeStore nodeStore = new MongoNodeStore(db);
+            BlobStore blobStore = new MongoGridFSBlobStore(db);
+            MicroKernel mk = new MongoMicroKernel(mongoConnection, nodeStore, blobStore);
 
-            MicroKernel mk = new MongoMicroKernel(nodeStore, blobStore);
             for (int i = 0; i < cluster.length; i++) {
                 cluster[i] = mk;
             }
@@ -77,9 +77,17 @@ public class MongoMicroKernelFixture imp
     @Override
     public void tearDownCluster(MicroKernel[] cluster) {
         try {
-            MongoUtil.clearDatabase(mongoConnection);
+            DB db = mongoConnection.getDB();
+            dropCollections(db);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
+
+    private void dropCollections(DB db) {
+        db.getCollection(MongoBlobStore.COLLECTION_BLOBS).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_COMMITS).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_NODES).drop();
+        db.getCollection(MongoNodeStore.COLLECTION_SYNC).drop();
+    }
 }

Added: jackrabbit/oak/trunk/oak-mongomk-test/src/test/resources/logback-test.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-test/src/test/resources/logback-test.xml?rev=1407119&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-test/src/test/resources/logback-test.xml (added)
+++ jackrabbit/oak/trunk/oak-mongomk-test/src/test/resources/logback-test.xml Thu Nov  8 15:17:50 2012
@@ -0,0 +1,39 @@
+<!--
+   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.
+  -->
+<configuration>
+
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="file" class="ch.qos.logback.core.FileAppender">
+        <file>target/unit-tests.log</file>
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <!--
+        <appender-ref ref="console"/>
+        -->
+        <appender-ref ref="file"/>
+    </root>
+
+</configuration>

Propchange: jackrabbit/oak/trunk/oak-mongomk-test/src/test/resources/logback-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-mongomk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/pom.xml?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk/pom.xml Thu Nov  8 15:17:50 2012
@@ -46,7 +46,10 @@
                             org.apache.jackrabbit.mongomk.*
                         </Private-Package>
                         <Export-Package>
-                            org.apache.jackrabbit.mongomk.api.*
+                            org.apache.jackrabbit.mongomk.api.*,
+                            org.apache.jackrabbit.mk.model.*,
+                            org.apache.jackrabbit.mk.store.*,
+                            org.apache.jackrabbit.mk.persistence.*
                         </Export-Package>
                         <Embed-Dependency>
                             org.apache.sling.commons.osgi;inline=org/apache/sling/commons/osgi/PropertiesUtil.class
@@ -142,6 +145,11 @@
         <version>1.0.1</version>
         <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>com.googlecode.json-simple</groupId>
+      <artifactId>json-simple</artifactId>
+      <version>1.1</version>
+    </dependency>
 
   </dependencies>
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/NodeStore.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/NodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/NodeStore.java Thu Nov  8 15:17:50 2012
@@ -17,39 +17,54 @@
 package org.apache.jackrabbit.mongomk.api;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
 import org.apache.jackrabbit.mongomk.api.model.Node;
 
 /**
- * The <code>NodeStore</code> interface deals with all node related operations of the {@link MicroKernel}.
+ * The <code>NodeStore</code> interface deals with all node related operations
+ * of the {@code MicroKernel}.
  *
  * <p>
- * Since binary storage and node storage most likely use different backend technologies two separate interfaces for
- * these operations are provided.
+ * Since binary storage and node storage most likely use different back-end
+ * technologies two separate interfaces for these operations are provided.
  * </p>
  *
  * <p>
- * This interface is not only a partly {@code MicroKernel} but also provides a different layer of abstraction by
- * converting the {@link String} parameters into higher level objects to ease the development for implementors of the
+ * This interface is not only a partly {@code MicroKernel} but also provides a
+ * different layer of abstraction by converting the {@link String} parameters
+ * into higher level objects to ease the development for implementors of the
  * {@code MicroKernel}.
  * </p>
  *
- * @see BlobStore
- *
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
+ * @see {@code BlobStore}
  */
 public interface NodeStore {
 
     /**
      * @see MicroKernel#commit(String, String, String, String)
      *
-     * @param commit The {@link Commit} object to store in the backend.
+     * @param commit The {@link Commit} object to store in the back-end.
      * @return The revision id of this commit.
      * @throws Exception If an error occurred while committing.
      */
     String commit(Commit commit) throws Exception;
 
     /**
+     * @see MicroKernel#diff(String, String, String, int)
+     *
+     * @param fromRevisionId a revision id, if {@code null} the current head revision is assumed
+     * @param toRevisionId another revision id, if {@code null} the current head revision is assumed
+     * @param path optional path filter; if {@code null} or {@code ""}.
+     * The default ({@code "/"}) will be assumed, i.e. no filter will be applied
+     * @param depth Depth limit; if {@code -1} no limit will be applied
+     * @return JSON diff representation of the changes
+     * @throws MicroKernelException if any of the specified revisions doesn't exist or if another error occurs
+     */
+    String diff(String fromRevisionId, String toRevisionId, String path, int depth)
+            throws Exception;
+
+    /**
      * @see MicroKernel#getHeadRevision()
      *
      * @return The revision id of the head revision.
@@ -66,8 +81,10 @@ public interface NodeStore {
      * @param path optional path filter; if {@code null} or {@code ""}
      * the default ({@code "/"}) will be assumed, i.e. no filter will be applied
      * @return a chronological list of revisions in JSON format
+     * @throws Exception if an error occurred while getting the journal.
      */
-    String getJournal(String fromRevisionId, String toRevisionId, String path);
+    String getJournal(String fromRevisionId, String toRevisionId, String path)
+            throws Exception;
 
     /**
      * @see MicroKernel#getRevisionHistory(long, int, String)
@@ -77,8 +94,9 @@ public interface NodeStore {
      * @param path optional path filter; if {@code null} or {@code ""} the default
      *  ({@code "/"}) will be assumed, i.e. no filter will be applied
      * @return a list of revisions in chronological order in JSON format.
+     * @throws Exception if an error occurred while getting the revision history.
      */
-    String getRevisionHistory(long since, int maxEntries, String path);
+    String getRevisionHistory(long since, int maxEntries, String path) throws Exception;;
 
     /**
      * @see MicroKernel#getNodes(String, String, int, long, int, String)
@@ -97,6 +115,16 @@ public interface NodeStore {
             String filter) throws Exception;
 
     /**
+     * @see MicroKernel#merge(String, String)
+     *
+     * @param branchRevisionId Branch revision id to merge.
+     * @param message Merge message.
+     * @return The revision id after merge.
+     * @throws Exception If an error occurred while merging.
+     */
+    String merge(String branchRevisionId, String message) throws Exception;
+
+    /**
      * @see MicroKernel#nodeExists(String, String)
      *
      * @param path The path of the node to test.
@@ -112,7 +140,7 @@ public interface NodeStore {
      * @param oldHeadRevisionId id of earlier head revision
      * @param timeout the maximum time to wait in milliseconds
      * @return the id of the head revision
-     * @throws InterruptedException if the thread was interrupted
+     * @throws Exception if an error occurred while waiting.
      */
-    String waitForCommit(String oldHeadRevisionId, long timeout) throws InterruptedException;
+    String waitForCommit(String oldHeadRevisionId, long timeout) throws Exception;
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/Command.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/Command.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/Command.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/Command.java Thu Nov  8 15:17:50 2012
@@ -16,39 +16,34 @@
  */
 package org.apache.jackrabbit.mongomk.api.command;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 
 /**
- * The {@code Command} framework provides an way to encapsulate specific actions of the {@link MicroKernel}.
+ * The {@code Command} framework provides an way to encapsulate specific actions
+ * of the {code MicroKernel}.
  *
  * <p>
- * It adds some functionality for retries and other non business logic related actions (i.e. logging, performance
- * tracking, etc).
+ * It adds some functionality for retries and other non business logic related
+ * actions (i.e. logging, performance tracking, etc).
  * </p>
  *
  * @see <a href="http://en.wikipedia.org/wiki/Command_pattern">Command Pattern</a>
  * @see CommandExecutor
  *
- * @param <T>
- *            The result type of the {@code Command}.
- *
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
+ * @param <T> The result type of the {@code Command}.
  */
 public interface Command<T> {
 
-    // TODO Add postExecute and preExecute; Maybe add AOP but only if Granite moves to OSGi 4.3
-
     /**
      * Executes the {@code Command} and returns its result.
      *
      * @return The result.
-     * @throws Exception
-     *             If an error occurred while executing.
+     * @throws Exception If an error occurred while executing.
      */
     T execute() throws Exception;
 
     /**
-     * Returns the number of retries this {@code Command} should be retried in case of an error or false result.
+     * Returns the number of retries this {@code Command} should be retried in
+     * case of an error or false result.
      *
      * <p>
      * The number of reties is evaluated in the following way:
@@ -58,8 +53,8 @@ public interface Command<T> {
      * </p>
      *
      * <p>
-     * In order to determine whether the {@code Command} should be retired on of {@link #needsRetry(Exception)} or
-     * {@link #needsRetry(Object)} will be called.
+     * In order to determine whether the {@code Command} should be retired on
+     * {@link #needsRetry(Exception)} or {@link #needsRetry(Object)} will be called.
      * </p>
      *
      * @see #needsRetry(Exception)
@@ -70,8 +65,8 @@ public interface Command<T> {
     int getNumOfRetries();
 
     /**
-     * Will be called in case of an {@link Exception} during the execution and a given number of retries which has not
-     * exceeded.
+     * Will be called in case of an {@link Exception} during the execution and
+     * a given number of retries which has not exceeded.
      *
      * @param e The Exception which was thrown.
      * @return {@code true} if a retry should be performed, else {@code false}.
@@ -79,7 +74,8 @@ public interface Command<T> {
     boolean needsRetry(Exception e);
 
     /**
-     * Will be called in case of a successful execution and a given number of retries which has not exceeded.
+     * Will be called in case of a successful execution and a given number of
+     * retries which has not exceeded.
      *
      * <p>
      * This gives the implementor a chance to retry a false result.

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/CommandExecutor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/CommandExecutor.java?rev=1407119&r1=1407118&r2=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/CommandExecutor.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/CommandExecutor.java Thu Nov  8 15:17:50 2012
@@ -25,8 +25,6 @@ package org.apache.jackrabbit.mongomk.ap
  *
  * @see <a href="http://en.wikipedia.org/wiki/Command_pattern">Command Pattern</a>
  * @see Command
- *
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
  */
 public interface CommandExecutor {
 

Copied: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java (from r1407101, jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/Instruction.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java?p2=jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java&p1=jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/Instruction.java&r1=1407101&r2=1407119&rev=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/Instruction.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java Thu Nov  8 15:17:50 2012
@@ -14,20 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mongomk.api.model;
+package org.apache.jackrabbit.mongomk.api.instruction;
+
 
 /**
- * An {@code Instruction} is an abstraction of a single <a href="http://wiki.apache.org/jackrabbit/Jsop">JSOP</a>
- * operation.
+ * FIXME - Remove other interfaces and renamed AddNodeInstructionImpl into
+ * AddNodeInstruction etc.
+ *
+ * An {@code Instruction} is an abstraction of a single
+ * <a href="http://wiki.apache.org/jackrabbit/Jsop">JSOP</a> operation.
  *
  * <p>
- * Each operation is a concrete subinterface of {@code Instruction} and extending it by the specific properties of the
- * operation. There is no exact 1 : 1 mapping between a {@code JSOP} operation and a subinterface, i.e. in {@code JSOP}
- * there is one add operation for adding nodes and properties whereas there are two specific subinterfaces; one for
- * adding a node and one for adding a property.
+ * Each operation is a concrete sub-interface of {@code Instruction} and extending
+ * it by the specific properties of the operation. There is no exact 1 : 1 mapping
+ * between a {@code JSOP} operation and a sub-interface, i.e. in {@code JSOP} there
+ * is one add operation for adding nodes and properties whereas there are two specific
+ * sub-interfaces; one for adding a node and one for adding a property.
  * </p>
- *
- * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
  */
 public interface Instruction {
 
@@ -56,26 +59,6 @@ public interface Instruction {
     }
 
     /**
-     * The add property operation => "+" STRING ":" (ATOM | ARRAY)
-     */
-    public interface AddPropertyInstruction extends Instruction {
-
-        /**
-         * Returns the key of the property to add.
-         *
-         * @return The key.
-         */
-        String getKey();
-
-        /**
-         * Returns the value of the property to add.
-         *
-         * @return The value.
-         */
-        Object getValue();
-    }
-
-    /**
      * The copy node operation => "*" STRING ":" STRING
      */
     public interface CopyNodeInstruction extends Instruction {

Propchange: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/Instruction.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Copied: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java (from r1407101, jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/InstructionVisitor.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java?p2=jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java&p1=jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/InstructionVisitor.java&r1=1407101&r2=1407119&rev=1407119&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/InstructionVisitor.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java Thu Nov  8 15:17:50 2012
@@ -14,35 +14,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mongomk.api.model;
+package org.apache.jackrabbit.mongomk.api.instruction;
 
-import org.apache.jackrabbit.mongomk.api.model.Instruction.AddNodeInstruction;
-import org.apache.jackrabbit.mongomk.api.model.Instruction.AddPropertyInstruction;
-import org.apache.jackrabbit.mongomk.api.model.Instruction.CopyNodeInstruction;
-import org.apache.jackrabbit.mongomk.api.model.Instruction.MoveNodeInstruction;
-import org.apache.jackrabbit.mongomk.api.model.Instruction.RemoveNodeInstruction;
-import org.apache.jackrabbit.mongomk.api.model.Instruction.SetPropertyInstruction;
+import org.apache.jackrabbit.mongomk.api.instruction.Instruction.AddNodeInstruction;
+import org.apache.jackrabbit.mongomk.api.instruction.Instruction.CopyNodeInstruction;
+import org.apache.jackrabbit.mongomk.api.instruction.Instruction.MoveNodeInstruction;
+import org.apache.jackrabbit.mongomk.api.instruction.Instruction.RemoveNodeInstruction;
+import org.apache.jackrabbit.mongomk.api.instruction.Instruction.SetPropertyInstruction;
 
 /**
- * A <a href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a> to iterate through a list of
- * {@code Instruction}s without the need to use {@code instanceof} on each item.
+ * A <a href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a> to iterate
+ * through a list of {@code Instruction}s without the need to use {@code instanceof}
+ * on each item.
  */
 public interface InstructionVisitor {
 
     /**
      * Visits a {@code AddNodeInstruction}.
      *
-     * @param instruction
-     *            The instruction.
-     */
-    void visit(AddNodeInstruction instruction);
-
-    /**
-     * Visits a {@code AddPropertyInstruction}.
-     *
      * @param instruction The instruction.
      */
-    void visit(AddPropertyInstruction instruction);
+    void visit(AddNodeInstruction instruction);
 
     /**
      * Visits a {@code CopyNodeInstruction}.

Propchange: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/instruction/InstructionVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message