add PdxTypeBenchmark test case and enhance the framework to
specify properties.
Co-authored-by: Xiaojian Zhou <gzhou@pivotal.io>
Co-authored-by: Donal Evans <doevans@pivotal.io>
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/CreatePdxFromJSONTask.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/CreatePdxFromJSONTask.java
new file mode 100644
index 0000000..88b5441
--- /dev/null
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/CreatePdxFromJSONTask.java
@@ -0,0 +1,69 @@
+/*
+ * 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.geode.benchmark.tasks;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkDriverAdapter;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.pdx.JSONFormatter;
+
+public class CreatePdxFromJSONTask extends BenchmarkDriverAdapter
+ implements Serializable {
+
+ // The number of PdxTypes to create per test execution.
+ private int batchSize;
+
+ private int count = 0;
+
+ private String member = null;
+
+ public CreatePdxFromJSONTask(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ @Override
+ public void setUp(BenchmarkConfiguration cfg) throws Exception {
+ // The test is by operationCounts, not by duration
+ // We are creating new pdxTypes, no need to warm up
+ // The performance is impacted on how many total pdxType when creating a
+ // new one. Each test starts from creating 10K new pdxType.
+ // Creating an existing pdxType will not impact the performance.
+ cfg.operationsCount(batchSize);
+ cfg.warmup(0);
+ cfg.duration(0);
+ super.setUp(cfg);
+ if (member == null) {
+ member = CacheFactory.getAnyInstance().getDistributedSystem()
+ .getDistributedMember().getName();
+ }
+ }
+
+ @Override
+ public boolean test(Map<Object, Object> ctx) throws Exception {
+ String field =
+ "\"" + member + "-" + Thread.currentThread().getName() + "-" + count +
+ "\": " + count;
+ String jsonString = "{" + field + "}";
+ JSONFormatter.fromJSON(jsonString);
+ count++;
+ return true;
+ }
+}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
index 77bb847..7fa933c 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
@@ -35,9 +35,11 @@
*/
public class StartClient implements Task {
private int locatorPort;
+ private Properties props;
- public StartClient(int locatorPort) {
+ public StartClient(int locatorPort, Properties props) {
this.locatorPort = locatorPort;
+ this.props = props;
}
@Override
@@ -48,6 +50,12 @@
String statsFile = new File(context.getOutputDir(), "stats.gfs").getAbsolutePath();
Properties properties = clientProperties();
+ if (this.props != null) {
+ for (String propertyName : props.stringPropertyNames()) {
+ properties.setProperty(propertyName, props.getProperty(propertyName));
+ }
+ }
+
ClientCache clientCache = new ClientCacheFactory(properties)
.setPdxSerializer(new ReflectionBasedAutoSerializer("benchmark.geode.data.*"))
.addPoolLocator(locator.getHostAddress(), locatorPort)
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
index c5f53ff..b53f445 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
@@ -33,15 +33,23 @@
*/
public class StartLocator implements Task {
private int locatorPort;
+ private Properties props;
- public StartLocator(int locatorPort) {
+ public StartLocator(int locatorPort, Properties props) {
this.locatorPort = locatorPort;
+ this.props = props;
}
@Override
public void run(TestContext context) throws Exception {
Properties properties = locatorProperties();
+ if (this.props != null) {
+ for (String propertyName : props.stringPropertyNames()) {
+ properties.setProperty(propertyName, props.getProperty(propertyName));
+ }
+ }
+
String statsFile = new File(context.getOutputDir(), "stats.gfs").getAbsolutePath();
properties.setProperty(ConfigurationProperties.STATISTIC_ARCHIVE_FILE, statsFile);
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
index 99b1543..64deb0e 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
@@ -37,15 +37,22 @@
public class StartServer implements Task {
private int locatorPort;
+ private Properties props;
- public StartServer(int locatorPort) {
+ public StartServer(int locatorPort, Properties props) {
this.locatorPort = locatorPort;
+ this.props = props;
}
@Override
public void run(TestContext context) throws Exception {
Properties properties = serverProperties();
+ if (this.props != null) {
+ for (String propertyName : props.stringPropertyNames()) {
+ properties.setProperty(propertyName, props.getProperty(propertyName));
+ }
+ }
String locatorString = LocatorUtil.getLocatorString(context, locatorPort);
String statsFile = new File(context.getOutputDir(), "stats.gfs").getAbsolutePath();
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmark.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmark.java
new file mode 100644
index 0000000..080ab3d
--- /dev/null
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmark.java
@@ -0,0 +1,64 @@
+/*
+ * 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.geode.benchmark.tests;
+
+import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.LOCATOR;
+import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.Properties;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.benchmark.tasks.CreatePdxFromJSONTask;
+import org.apache.geode.benchmark.topology.ClientServerTopology;
+import org.apache.geode.perftest.PerformanceTest;
+import org.apache.geode.perftest.TestConfig;
+import org.apache.geode.perftest.TestRunners;
+
+/**
+ * Benchmark of puts on a replicated region.
+ */
+public class CreatePdxFromJSONBenchmark implements PerformanceTest {
+
+ private int batchSize = 10000;
+
+ public CreatePdxFromJSONBenchmark() {}
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ @Test
+ public void run() throws Exception {
+ TestRunners.defaultRunner().runTest(this);
+ }
+
+ @Override
+ public TestConfig configure() {
+ TestConfig config = GeodeBenchmark.createConfig();
+ Properties customProps = new Properties();
+ customProps.setProperty(LOG_LEVEL, "WARN");
+ config.props(SERVER, customProps);
+ config.props(LOCATOR, customProps);
+ ClientServerTopology.configure(config);
+ config.workload(new CreatePdxFromJSONTask(batchSize), SERVER);
+ return config;
+
+ }
+}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopology.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopology.java
index 384fa92..d16b268 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopology.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopology.java
@@ -20,6 +20,9 @@
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.LOCATOR;
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER;
+import java.util.Map;
+import java.util.Properties;
+
import org.bouncycastle.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,9 +75,11 @@
addToTestConfig(testConfig, "withSsl", WITH_SSL_ARGUMENT);
addToTestConfig(testConfig, "withSecurityManager", WITH_SECURITY_MANAGER_ARGUMENT);
- testConfig.before(new StartLocator(LOCATOR_PORT), LOCATOR);
- testConfig.before(new StartServer(LOCATOR_PORT), SERVER);
- testConfig.before(new StartClient(LOCATOR_PORT), CLIENT);
+ Map<String, Properties> propertiesMap = testConfig.getProps();
+
+ testConfig.before(new StartLocator(LOCATOR_PORT, propertiesMap.get(LOCATOR)), LOCATOR);
+ testConfig.before(new StartServer(LOCATOR_PORT, propertiesMap.get(SERVER)), SERVER);
+ testConfig.before(new StartClient(LOCATOR_PORT, propertiesMap.get(CLIENT)), CLIENT);
}
private static void addToTestConfig(TestConfig testConfig, String systemPropertyKey,
diff --git a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmarkTest.java b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmarkTest.java
new file mode 100644
index 0000000..39297f5
--- /dev/null
+++ b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/CreatePdxFromJSONBenchmarkTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.geode.benchmark.tests;
+
+import java.io.File;
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junitpioneer.jupiter.TempDirectory;
+
+import org.apache.geode.perftest.TestRunners;
+
+@ExtendWith(TempDirectory.class)
+public class CreatePdxFromJSONBenchmarkTest {
+
+ private File folder;
+
+ @BeforeEach
+ void createTemporaryFolder(@TempDirectory.TempDir Path tempFolder) {
+ folder = tempFolder.toFile();
+ }
+
+ @Test
+ public void benchmarkRunsSuccessfully()
+ throws Exception {
+ CreatePdxFromJSONBenchmark test = new CreatePdxFromJSONBenchmark();
+ TestRunners.minimalRunner(folder)
+ .runTest(test);
+ }
+}
diff --git a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/PartitionedPutBenchmarkTest.java b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/PartitionedPutBenchmarkTest.java
index d724508..7a5d403 100644
--- a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/PartitionedPutBenchmarkTest.java
+++ b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/tests/PartitionedPutBenchmarkTest.java
@@ -17,8 +17,6 @@
package org.apache.geode.benchmark.tests;
-
-
import java.io.File;
import java.nio.file.Path;
diff --git a/harness/src/main/java/org/apache/geode/perftest/TestConfig.java b/harness/src/main/java/org/apache/geode/perftest/TestConfig.java
index 9d66cd6..daf877f 100644
--- a/harness/src/main/java/org/apache/geode/perftest/TestConfig.java
+++ b/harness/src/main/java/org/apache/geode/perftest/TestConfig.java
@@ -25,6 +25,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.yardstickframework.BenchmarkDriver;
@@ -40,6 +41,7 @@
private final WorkloadConfig workloadConfig = new WorkloadConfig();
private Map<String, Integer> roles = new LinkedHashMap<>();
private Map<String, List<String>> jvmArgs = new HashMap<>();
+ private Map<String, Properties> props = new HashMap<>();
private List<TestStep> before = new ArrayList<>();
private List<TestStep> workload = new ArrayList<>();
private List<TestStep> after = new ArrayList<>();
@@ -54,7 +56,6 @@
this.roles.put(role, numberOfJVMs);
}
-
/**
* Add a before task to the test. Each before task is run in parallel on
* all of the nodes that have the given role
@@ -161,6 +162,17 @@
return Collections.unmodifiableMap(jvmArgs);
}
+ /**
+ * Add custom system properties to be used by Servers, Locators and Clients upon startup
+ */
+ public void props(String role, Properties props) {
+ this.props.put(role, props);
+ }
+
+ public Map<String, Properties> getProps() {
+ return Collections.unmodifiableMap(props);
+ }
+
public static class TestStep {
private final Task task;
private final String[] roles;
@@ -180,5 +192,6 @@
public String[] getRoles() {
return roles;
}
+
}
}