You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2013/11/06 09:48:03 UTC
svn commit: r1539273 -
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java
Author: mreutegg
Date: Wed Nov 6 08:48:03 2013
New Revision: 1539273
URL: http://svn.apache.org/r1539273
Log:
OAK-1099: node creation noticeably slower with mongoMk compared to tarMk
- adjust benchmark to better reflect the test case. the benchmark now only creates nodes and does not remove nodes anymore in the run method.
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java?rev=1539273&r1=1539272&r2=1539273&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java Wed Nov 6 08:48:03 2013
@@ -23,48 +23,52 @@ import javax.jcr.Session;
public class ConcurrentCreateNodesTest extends AbstractTest {
protected static final String ROOT_NODE_NAME = "test" + TEST_ID;
- private static final int WORKER_COUNT = 20;
- private static final int NODE_COUNT_LEVEL2 = 50;
+ private static final int WORKER_COUNT = 20;
+ private static final int NODE_COUNT_LEVEL2 = 50;
+ private Writer writer;
- @Override
- protected void beforeSuite() throws Exception {
+ @Override
+ protected void beforeSuite() throws Exception {
Session session = loginWriter();
Node rootNode = session.getRootNode();
if (rootNode.hasNode(ROOT_NODE_NAME)) {
- Node root = rootNode.getNode(ROOT_NODE_NAME);
- root.remove();
+ Node root = rootNode.getNode(ROOT_NODE_NAME);
+ root.remove();
+ }
+ rootNode = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
+ for (int i = 0; i < WORKER_COUNT; i++) {
+ rootNode.addNode("node" + i);
}
- Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
session.save();
for (int i = 1; i < WORKER_COUNT; i++) {
- addBackgroundJob(new Writer(i));
+ addBackgroundJob(new Writer(rootNode.getPath() + "/node" + i));
}
+ writer = new Writer(rootNode.getPath() + "/node" + 0);
}
private class Writer implements Runnable {
private final Session session = loginWriter();
- private final int id;
+ private final String path;
+ private int count = 0;
- private Writer(int id) {
- this.id = id;
+ private Writer(String path) {
+ this.path = path;
}
-
+
@Override
public void run() {
try {
session.refresh(false);
-
- Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
- Node node = root.addNode("node" + id, "nt:unstructured");
+
+ Node root = session.getNode(path);
+ Node node = root.addNode("node" + count++);
for (int j = 0; j < NODE_COUNT_LEVEL2; j++) {
- Node newNode = node.addNode("node" + j, "nt:unstructured");
+ node.addNode("node" + j);
session.save();
}
- node.remove();
- session.save();
} catch (RepositoryException e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -73,15 +77,6 @@ public class ConcurrentCreateNodesTest e
@Override
public void runTest() throws Exception {
- new Writer(0).run();
- }
-
- @Override
- protected void afterSuite() throws Exception {
- Session session = loginWriter();
- Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
- root.remove();
- session.save();
+ writer.run();
}
-
}