diff --git a/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java b/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java index 3391dbf..b985031 100644 --- a/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java +++ b/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java @@ -89,6 +89,8 @@ public abstract class AbstractTest extends Benchmark implements CSVResultGene private PrintStream out; + private RepositoryFixture currentFixture; + /** *

* used to signal the {@link #runTest(int)} if stop running future test planned or not. If set @@ -191,6 +193,7 @@ public abstract class AbstractTest extends Benchmark implements CSVResultGene toString(), statsNamesJoined(true)); } for (RepositoryFixture fixture : fixtures) { + currentFixture = fixture; try { Repository[] cluster = createRepository(fixture); try { @@ -529,6 +532,10 @@ public abstract class AbstractTest extends Benchmark implements CSVResultGene return credentials; } + protected RepositoryFixture getCurrentFixture() { + return currentFixture; + } + /** * Returns a new reader session that will be automatically closed once * all the iterations of this test have been executed. diff --git a/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java b/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java index 438436c..43b5522 100644 --- a/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java +++ b/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.benchmark; +import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -24,6 +25,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeTypeManager; +import org.apache.jackrabbit.oak.fixture.RepositoryFixture; + import com.google.common.collect.Maps; /** @@ -32,7 +35,12 @@ import com.google.common.collect.Maps; */ public class SetPropertyTest extends AbstractTest { - private Map nodes = Maps.newIdentityHashMap(); + /** + * Map holding node to be tested (below testNodeName) per current running fixture, per thread. + * A simpler structure holding nodes on a per thread basis is not enough, as runs with concurrencyLevel==1 + * and warm-up in {@link AbstractTest} are done from the same thread (re-using it between fixtures). + */ + private Map> map = new HashMap<>(); String testNodeName = "test" + TEST_ID; @@ -46,6 +54,8 @@ public class SetPropertyTest extends AbstractTest { @Override public void beforeTest() throws RepositoryException { + Map nodes = getOrCreateNodesMap(); + Thread t = Thread.currentThread(); Node node = nodes.get(t); if (node == null) { @@ -54,11 +64,14 @@ public class SetPropertyTest extends AbstractTest { node.setProperty("count", -1); s.save(); nodes.put(t, node); + map.put(getCurrentFixture().toString(), nodes); } } @Override public void runTest() throws Exception { + Map nodes = getOrCreateNodesMap(); + Node node = nodes.get(Thread.currentThread()); Session session = node.getSession(); for (int i = 0; i < 1000; i++) { @@ -85,4 +98,18 @@ public class SetPropertyTest extends AbstractTest { } } + private Map getOrCreateNodesMap() { + RepositoryFixture currentFixture = getCurrentFixture(); + if (currentFixture == null) { + throw new RuntimeException("Current running fixture was not correctly set!"); + } + + String currentFixtureName = currentFixture.toString(); + + Map nodes = map.get(currentFixtureName); + if (nodes == null) { + nodes = Maps.newIdentityHashMap(); + } + return nodes; + } }