You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by vj...@apache.org on 2021/05/29 06:21:05 UTC
[phoenix] 06/06: PHOENIX-6432 Add support for additional load
generators
This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git
commit efda46ad6a0560cfe9c03073912288e6a08e681a
Author: jpisaac <ja...@gmail.com>
AuthorDate: Fri May 7 21:16:07 2021 -0700
PHOENIX-6432 Add support for additional load generators
---
phoenix-pherf/pom.xml | 13 ++
.../MultiTenantTestUtils.java | 201 ++++++++++++++-------
.../mt/TenantTableOperationWorkloadIT.java | 149 +++++++++++++++
.../workload/mt/TenantViewOperationWorkloadIT.java | 157 ++++++++++++++++
.../MultiTenantTableOperationBaseIT.java | 77 --------
.../MultiTenantViewOperationBaseIT.java | 81 ---------
.../TenantTableOperationWorkloadIT.java | 72 --------
.../TenantViewOperationWorkloadIT.java | 61 -------
.../main/java/org/apache/phoenix/pherf/Pherf.java | 33 +++-
.../org/apache/phoenix/pherf/PherfConstants.java | 6 +
.../phoenix/pherf/configuration/Scenario.java | 15 ++
.../apache/phoenix/pherf/configuration/Upsert.java | 2 -
.../org/apache/phoenix/pherf/util/PhoenixUtil.java | 13 ++
.../phoenix/pherf/workload/mt/EventGenerator.java | 30 ---
.../pherf/workload/mt/MultiTenantWorkload.java | 63 +++++--
.../BaseLoadEventGenerator.java} | 177 ++++++++++--------
.../LoadEventGenerator.java} | 30 ++-
.../LoadEventGeneratorFactory.java} | 33 ++--
.../generators/SequentialLoadEventGenerator.java | 187 +++++++++++++++++++
.../TenantLoadEventGeneratorFactory.java | 70 +++++++
.../TenantOperationInfo.java | 4 +-
.../UniformDistributionLoadEventGenerator.java | 109 +++++++++++
.../WeightedRandomLoadEventGenerator.java} | 30 +--
.../PherfWorkHandler.java} | 14 +-
.../RendezvousingWorkHandler.java} | 54 ++++--
.../TenantOperationWorkHandler.java | 26 ++-
.../BaseOperationSupplier.java | 6 +-
.../mt/{ => operations}/IdleTimeOperation.java | 2 +-
.../IdleTimeOperationSupplier.java | 7 +-
.../workload/mt/{ => operations}/Operation.java | 2 +-
.../mt/{ => operations}/OperationStats.java | 49 ++---
.../mt/{ => operations}/PreScenarioOperation.java | 2 +-
.../PreScenarioOperationSupplier.java | 8 +-
.../mt/{ => operations}/QueryOperation.java | 2 +-
.../QueryOperationSupplier.java | 5 +-
.../TenantOperationFactory.java | 78 +++++---
.../mt/{ => operations}/UpsertOperation.java | 2 +-
.../UpsertOperationSupplier.java | 7 +-
.../mt/{ => operations}/UserDefinedOperation.java | 2 +-
.../UserDefinedOperationSupplier.java | 7 +-
.../phoenix/pherf/ConfigurationParserTest.java | 26 ++-
.../java/org/apache/phoenix/pherf/PherfTest.java | 2 +-
.../mt/SequentialLoadEventGeneratorTest.java | 146 +++++++++++++++
.../TenantOperationFactoryTest.java | 20 +-
.../UniformDistributionLoadEventGeneratorTest.java | 136 ++++++++++++++
...a => WeightedRandomLoadEventGeneratorTest.java} | 39 ++--
...ase_table.sql => test_mt_schema_base_table.sql} | 0
...chema_mt_view1.sql => test_mt_schema_view1.sql} | 0
...chema_mt_view2.sql => test_mt_schema_view2.sql} | 0
...a_tbl_simple.sql => test_tbl_schema_simple.sql} | 0
.../src/test/resources/scenario/test_evt_gen1.xml | 8 +-
.../src/test/resources/scenario/test_evt_gen2.xml | 30 +--
.../{test_evt_gen2.xml => test_evt_gen3.xml} | 42 ++---
.../{test_evt_gen2.xml => test_evt_gen4.xml} | 42 ++---
..._workload.xml => test_mt_workload_template.xml} | 40 ++--
...workload.xml => test_tbl_workload_template.xml} | 4 +-
.../scenario/test_workload_with_load_profile.xml | 12 +-
57 files changed, 1676 insertions(+), 757 deletions(-)
diff --git a/phoenix-pherf/pom.xml b/phoenix-pherf/pom.xml
index bb0409c..5cbc778 100644
--- a/phoenix-pherf/pom.xml
+++ b/phoenix-pherf/pom.xml
@@ -162,6 +162,10 @@
<groupId>org.apache.hbase.thirdparty</groupId>
<artifactId>hbase-shaded-miscellaneous</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-server</artifactId>
+ </dependency>
<!-- Test Dependencies -->
<dependency>
@@ -183,6 +187,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-server</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -256,6 +266,9 @@
<configuration>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>
+ org.apache.hbase.thirdparty:hbase-shaded-miscellaneous
+ </ignoredUnusedDeclaredDependency>
+ <ignoredUnusedDeclaredDependency>
javax.activation:activation
</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTestUtils.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/MultiTenantTestUtils.java
similarity index 55%
rename from phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTestUtils.java
rename to phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/MultiTenantTestUtils.java
index fe535eb..cac2431 100644
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTestUtils.java
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/MultiTenantTestUtils.java
@@ -16,36 +16,54 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt;
import com.lmax.disruptor.LifecycleAware;
-import com.lmax.disruptor.WorkHandler;
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.XMLConfigParserTest;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.LoadProfile;
import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.configuration.XMLConfigParser;
+import org.apache.phoenix.pherf.result.ResultValue;
+import org.apache.phoenix.pherf.schema.SchemaReader;
import org.apache.phoenix.pherf.util.PhoenixUtil;
import org.apache.phoenix.pherf.workload.Workload;
-import org.apache.phoenix.pherf.workload.mt.Operation;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
+import org.apache.phoenix.pherf.workload.WorkloadExecutor;
+import org.apache.phoenix.pherf.workload.mt.generators.LoadEventGenerator;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantLoadEventGeneratorFactory;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.operations.IdleTimeOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
+import org.apache.phoenix.pherf.workload.mt.operations.OperationStats;
+import org.apache.phoenix.pherf.workload.mt.operations.QueryOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.apache.phoenix.pherf.workload.mt.operations.UpsertOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.UserDefinedOperationSupplier;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.pherf.workload.mt.generators.BaseLoadEventGenerator.TenantOperationEvent;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class MultiTenantTestUtils {
@@ -54,16 +72,43 @@ public class MultiTenantTestUtils {
upsertOp, queryOp1, queryOp2, idleOp, udfOp
}
- public void testWorkloadWithOneHandler(Properties properties, DataModel model,
- String scenarioName, int expectedTenantGroups, int expectedOpGroups) throws Exception {
+ public static class TestConfigAndExpectations {
+ List<TenantGroup> tenantGroups;
+ int expectedTenantGroups;
+ int expectedOpGroups;
+ }
+
+ public SchemaReader applySchema(PhoenixUtil util, String matcherSchema) throws Exception {
+ PherfConstants constants = PherfConstants.create();
+
+ PhoenixUtil.setZookeeper("localhost");
+ SchemaReader reader = new SchemaReader(util, matcherSchema);
+ reader.applySchema();
+ List<Path> resources = new ArrayList<>(reader.getResourceList());
+
+ assertTrue("Could not pull list of schema files.", resources.size() > 0);
+ assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
+ return reader;
+ }
+
+ public DataModel readTestDataModel(String resourceName) throws Exception {
+ URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
+ assertNotNull(scenarioUrl);
+ Path p = Paths.get(scenarioUrl.toURI());
+ return XMLConfigParser.readDataModel(p);
+ }
- int numHandlers = 1;
- int totalOperations = 50;
+ public void testWorkloadWithCountingHandlers(Properties properties, DataModel model,
+ String scenarioName,
+ int numHandlers,
+ int expectedTenantGroups, int expectedOpGroups) throws Exception {
+
+ int totalOperations = 500;
int perHandlerCount = 50;
- ExecutorService executor = null;
+ List<Workload> workloads = new ArrayList<>();
+ WorkloadExecutor workloadExecutor = new WorkloadExecutor(properties, workloads, false);
try {
- executor = Executors.newFixedThreadPool(numHandlers);
PhoenixUtil pUtil = PhoenixUtil.create();
for (Scenario scenario : model.getScenarios()) {
if (scenarioName != null && !scenarioName.isEmpty()
@@ -75,26 +120,30 @@ public class MultiTenantTestUtils {
// Set the total number of operations for this load profile
loadProfile.setNumOperations(totalOperations);
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model,
- scenario);
+ TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
assertEquals("tenant group size is not as expected: ", expectedTenantGroups,
loadProfile.getTenantDistribution().size());
+
assertEquals("operation group size from the factory is not as expected: ",
expectedOpGroups, opFactory.getOperations().size());
// populate the handlers and countdown latches.
- String handlerId = String
- .format("%s.%d", InetAddress.getLocalHost().getHostName(), numHandlers);
- List<WorkHandler> workers = Lists.newArrayList();
+ List<PherfWorkHandler> workers = Lists.newArrayList();
Map<String, CountDownLatch> latches = Maps.newConcurrentMap();
- workers.add(new EventCountingWorkHandler(opFactory, handlerId, latches));
- latches.put(handlerId, new CountDownLatch(perHandlerCount));
+ for (int i = 0; i < numHandlers; i++) {
+ String handlerId = String
+ .format("%s.%d", InetAddress.getLocalHost().getHostName(), i);
+ workers.add(new EventCountingWorkHandler(opFactory, handlerId, latches));
+ latches.put(handlerId, new CountDownLatch(perHandlerCount));
+ }
+
// submit the workload
- Workload workload = new TenantOperationWorkload(pUtil, model, scenario, workers,
+ Workload workload = new MultiTenantWorkload(pUtil, model, scenario, workers,
properties);
- Future status = executor.submit(workload.execute());
+ workloads.add(workload);
+ workloadExecutor.add(workload);
// Just make sure there are no exceptions
- status.get();
+ workloadExecutor.get();
// Wait for the handlers to count down
for (Map.Entry<String, CountDownLatch> latch : latches.entrySet()) {
@@ -102,59 +151,67 @@ public class MultiTenantTestUtils {
}
}
} finally {
- if (executor != null) {
- executor.shutdown();
+ if (!workloads.isEmpty()) {
+ for (Workload workload : workloads) {
+ workload.complete();
+ }
}
+ workloadExecutor.complete();
+ workloadExecutor.shutdown();
}
+
}
- public void testWorkloadWithManyHandlers(Properties properties, DataModel model,
- String scenarioName, int expectedTenantGroups, int expectedOpGroups) throws Exception {
+ public void testWorkloadWithHandlers(Properties properties, DataModel model,
+ String scenarioName,
+ int numHandlers,
+ int expectedTenantGroups, int expectedOpGroups) throws Exception {
- int numHandlers = 5;
int totalOperations = 500;
- int perHandlerCount = 50;
- ExecutorService executor = Executors.newFixedThreadPool(numHandlers);
- PhoenixUtil pUtil = PhoenixUtil.create();
- for (Scenario scenario : model.getScenarios()) {
- if (scenarioName != null && !scenarioName.isEmpty()
- && scenario.getName().compareTo(scenarioName) != 0) {
- continue;
- }
- LOGGER.debug(String.format("Testing %s", scenario.getName()));
- LoadProfile loadProfile = scenario.getLoadProfile();
+ List<Workload> workloads = new ArrayList<>();
+ WorkloadExecutor workloadExecutor = new WorkloadExecutor(properties, workloads, false);
+ try {
+ PhoenixUtil pUtil = PhoenixUtil.create();
+ for (Scenario scenario : model.getScenarios()) {
+ if (scenarioName != null && !scenarioName.isEmpty()
+ && scenario.getName().compareTo(scenarioName) != 0) {
+ continue;
+ }
- // Set the total number of operations for this load profile
- loadProfile.setNumOperations(totalOperations);
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
- assertEquals("tenant group size is not as expected: ", expectedTenantGroups,
- loadProfile.getTenantDistribution().size());
+ Map<String, String> scenarioProperties = Maps.newHashMap();
+ scenarioProperties.put("pherf.mt.handlers_per_scenario", String.valueOf(numHandlers));
+ scenario.setPhoenixProperties(scenarioProperties);
+ LOGGER.debug(String.format("Testing %s", scenario.getName()));
+ LoadProfile loadProfile = scenario.getLoadProfile();
- assertEquals("operation group size from the factory is not as expected: ",
- expectedOpGroups, opFactory.getOperations().size());
+ // Set the total number of operations for this load profile
+ loadProfile.setNumOperations(totalOperations);
+ TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
+ assertEquals("tenant group size is not as expected: ", expectedTenantGroups,
+ loadProfile.getTenantDistribution().size());
+
+ assertEquals("operation group size from the factory is not as expected: ",
+ expectedOpGroups, opFactory.getOperations().size());
+ // submit the workload
+ Workload workload = new MultiTenantWorkload(pUtil, model, scenario,
+ properties);
+ workloads.add(workload);
+ workloadExecutor.add(workload);
+ // Just make sure there are no exceptions
+ workloadExecutor.get();
- // populate the handlers and countdown latches.
- List<WorkHandler> workers = Lists.newArrayList();
- Map<String, CountDownLatch> latches = Maps.newConcurrentMap();
- for (int i = 0; i < numHandlers; i++) {
- String handlerId = String
- .format("%s.%d", InetAddress.getLocalHost().getHostName(), i);
- workers.add(new EventCountingWorkHandler(opFactory, handlerId, latches));
- latches.put(handlerId, new CountDownLatch(perHandlerCount));
}
- // submit the workload
- Workload workload = new TenantOperationWorkload(pUtil, model, scenario, workers,
- properties);
- Future status = executor.submit(workload.execute());
- // Just make sure there are no exceptions
- status.get();
- // Wait for the handlers to count down
- for (Map.Entry<String, CountDownLatch> latch : latches.entrySet()) {
- assertTrue(latch.getValue().await(60, TimeUnit.SECONDS));
+ } finally {
+ if (!workloads.isEmpty()) {
+ for (Workload workload : workloads) {
+ workload.complete();
+ }
}
+ workloadExecutor.complete();
+ workloadExecutor.shutdown();
}
- executor.shutdown();
+
}
public void testVariousOperations(Properties properties, DataModel model, String scenarioName,
@@ -176,9 +233,10 @@ public class MultiTenantTestUtils {
assertEquals("operation group size is not as expected: ", expectedOpGroups,
loadProfile.getOpDistribution().size());
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
- TenantOperationEventGenerator evtGen = new TenantOperationEventGenerator(
- opFactory.getOperations(), model, scenario);
+ TenantLoadEventGeneratorFactory eventGenFactory = new TenantLoadEventGeneratorFactory();
+ LoadEventGenerator evtGen = eventGenFactory.newLoadEventGenerator(
+ pUtil, model, scenario, properties);
+ TenantOperationFactory opFactory = evtGen.getOperationFactory();
assertEquals("operation group size from the factory is not as expected: ",
expectedOpGroups, opFactory.getOperations().size());
@@ -189,6 +247,7 @@ public class MultiTenantTestUtils {
loadProfile.setNumOperations(ops);
while (ops-- > 0) {
TenantOperationInfo info = evtGen.next();
+ opFactory.initializeTenant(info);
Supplier<Function<TenantOperationInfo, OperationStats>> opSupplier = opFactory
.getOperationSupplier(info);
OperationStats stats = opSupplier.get().apply(info);
@@ -217,7 +276,7 @@ public class MultiTenantTestUtils {
.isAssignableFrom(IdleTimeOperationSupplier.class));
assertEquals(0, stats.getRowCount());
// expected think time (no-op) to be ~50ms
- assertTrue(40 < stats.getDurationInMs() && stats.getDurationInMs() < 60);
+ assertTrue(25 < stats.getDurationInMs() && stats.getDurationInMs() < 75);
break;
case udfOp:
assertTrue(opFactory.getOperationSupplier(info).getClass()
@@ -233,7 +292,7 @@ public class MultiTenantTestUtils {
}
private static class EventCountingWorkHandler
- implements WorkHandler<TenantOperationWorkload.TenantOperationEvent>, LifecycleAware {
+ implements PherfWorkHandler<TenantOperationEvent>, LifecycleAware {
private final String handlerId;
private final TenantOperationFactory tenantOperationFactory;
private final Map<String, CountDownLatch> latches;
@@ -251,7 +310,7 @@ public class MultiTenantTestUtils {
@Override public void onShutdown() {
}
- @Override public void onEvent(TenantOperationWorkload.TenantOperationEvent event)
+ @Override public void onEvent(TenantOperationEvent event)
throws Exception {
TenantOperationInfo input = event.getTenantOperationInfo();
Supplier<Function<TenantOperationInfo, OperationStats>>
@@ -262,6 +321,10 @@ public class MultiTenantTestUtils {
assertEquals(0, stats.getStatus());
latches.get(handlerId).countDown();
}
+
+ @Override public List<ResultValue<OperationStats>> getResults() {
+ return null;
+ }
}
}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantTableOperationWorkloadIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantTableOperationWorkloadIT.java
new file mode 100644
index 0000000..e65790f
--- /dev/null
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantTableOperationWorkloadIT.java
@@ -0,0 +1,149 @@
+/*
+ * 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.phoenix.pherf.workload.mt;
+
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
+import com.lmax.disruptor.WorkHandler;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantLoadEventGeneratorFactory.GeneratorType;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantTestUtils.TestConfigAndExpectations;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Tests focused on tenant tablee operations and their validations
+ * Tests focused on tenant operation workloads {@link MultiTenantWorkload}
+ * and workload handlers {@link WorkHandler}
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+@RunWith(Parameterized.class)
+public class TenantTableOperationWorkloadIT extends ParallelStatsDisabledIT {
+
+ private final MultiTenantTestUtils multiTenantTestUtils = new MultiTenantTestUtils();
+ private final Properties properties = PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+ private final PhoenixUtil util = PhoenixUtil.create(true);
+ private GeneratorType generatorType;
+
+ public TenantTableOperationWorkloadIT(String generatorType) throws Exception {
+ this.generatorType = GeneratorType.valueOf(generatorType);
+ }
+
+ @Parameterized.Parameters( name = "generator_type={0}" )
+ public static synchronized Collection<Object[]> data() {
+ List<Object[]> testCases = Lists.newArrayList();
+ testCases.add(new Object[] { "WEIGHTED" });
+ testCases.add(new Object[] { "UNIFORM" });
+ testCases.add(new Object[] { "SEQUENTIAL" });
+ return testCases;
+ }
+
+ @Before
+ public void setup() throws Exception {
+ multiTenantTestUtils.applySchema(util, ".*datamodel/.*test_tbl_schema_simple.sql");
+ }
+
+ @After
+ public void cleanup() throws Exception {
+ util.deleteTables("PHERF.*MULTI_TENANT_TABLE");
+ }
+
+ @Test
+ public void testVariousOperations() throws Exception {
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_tbl_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testVariousOperations(properties, model, scenario.getName(),
+ settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ @Test
+ public void testWorkloadWithOneHandler() throws Exception {
+ int numHandlers = 1;
+
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_tbl_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testWorkloadWithHandlers(properties, model, scenario.getName(),
+ numHandlers, settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ @Test
+ public void testWorkloadWithManyHandlers() throws Exception {
+ int numHandlers = 5;
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_tbl_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testWorkloadWithHandlers(properties, model, scenario.getName(),
+ numHandlers, settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ private TestConfigAndExpectations getTestConfigAndExpectations(
+ Scenario scenario, GeneratorType generatorType) {
+
+ TestConfigAndExpectations
+ settings = new TestConfigAndExpectations();
+
+ switch (generatorType) {
+ case WEIGHTED:
+ settings.tenantGroups = scenario.getLoadProfile().getTenantDistribution();
+ settings.expectedOpGroups = scenario.getLoadProfile().getOpDistribution().size();
+ settings.expectedTenantGroups = scenario.getLoadProfile().getTenantDistribution().size();
+ default:
+ List<TenantGroup> tenantGroups = new ArrayList<>();
+ TenantGroup tg1 = new TenantGroup();
+ tg1.setId("tg1");
+ tg1.setNumTenants(10);
+ tg1.setWeight(100);
+ tenantGroups.add(tg1);
+ settings.tenantGroups = tenantGroups;
+ settings.expectedTenantGroups = 1;
+ settings.expectedOpGroups = scenario.getLoadProfile().getOpDistribution().size();;
+ break;
+ }
+ return settings;
+ }
+}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantViewOperationWorkloadIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantViewOperationWorkloadIT.java
new file mode 100644
index 0000000..88cac4f
--- /dev/null
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/TenantViewOperationWorkloadIT.java
@@ -0,0 +1,157 @@
+/*
+ * 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.phoenix.pherf.workload.mt;
+
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
+import com.lmax.disruptor.WorkHandler;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.phoenix.coprocessor.TaskRegionObserver;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantLoadEventGeneratorFactory.GeneratorType;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantTestUtils.TestConfigAndExpectations;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Tests focused on tenant view operations and their validations
+ * Tests focused on tenant operation workloads {@link MultiTenantWorkload}
+ * and workload handlers {@link WorkHandler}
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+@RunWith(Parameterized.class)
+public class TenantViewOperationWorkloadIT extends ParallelStatsDisabledIT {
+ private final MultiTenantTestUtils multiTenantTestUtils = new MultiTenantTestUtils();
+ private final Properties properties = PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+ private final PhoenixUtil util = PhoenixUtil.create(true);
+ private final RegionCoprocessorEnvironment taskRegionEnvironment;
+ private GeneratorType generatorType;
+
+ public TenantViewOperationWorkloadIT(String generatorType) throws Exception {
+ this.generatorType = GeneratorType.valueOf(generatorType);
+ taskRegionEnvironment =
+ (RegionCoprocessorEnvironment)getUtility()
+ .getRSForFirstRegionInTable(
+ PhoenixDatabaseMetaData.SYSTEM_TASK_HBASE_TABLE_NAME)
+ .getRegions(PhoenixDatabaseMetaData.SYSTEM_TASK_HBASE_TABLE_NAME)
+ .get(0).getCoprocessorHost()
+ .findCoprocessorEnvironment(TaskRegionObserver.class.getName());
+ }
+
+ @Parameterized.Parameters( name = "generator_type={0}" )
+ public static synchronized Collection<Object[]> data() {
+ List<Object[]> testCases = Lists.newArrayList();
+ testCases.add(new Object[] { "WEIGHTED" });
+ testCases.add(new Object[] { "UNIFORM" });
+ testCases.add(new Object[] { "SEQUENTIAL" });return testCases;
+ }
+
+ @Before
+ public void setup() throws Exception {
+ multiTenantTestUtils.applySchema(util,".*datamodel/.*test_mt.*.sql");
+ }
+
+ @After
+ public void cleanup() throws Exception {
+ util.deleteTables("PHERF.*BASE_TABLE");
+ if (taskRegionEnvironment != null) {
+ util.dropChildView(taskRegionEnvironment, 2);
+ }
+ }
+
+ @Test public void testVariousOperations() throws Exception {
+
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_mt_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testVariousOperations(properties, model, scenario.getName(),
+ settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ @Test public void testWorkloadWithOneHandler() throws Exception {
+ int numHandlers = 1;
+
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_mt_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testWorkloadWithHandlers(properties, model, scenario.getName(),
+ numHandlers, settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ @Test public void testWorkloadWithManyHandlers() throws Exception {
+ int numHandlers = 5;
+ DataModel model = multiTenantTestUtils.readTestDataModel(
+ "/scenario/test_mt_workload_template.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ TestConfigAndExpectations settings = getTestConfigAndExpectations(scenario, generatorType);
+ scenario.setGeneratorName(generatorType.name());
+ scenario.getLoadProfile().setTenantDistribution(settings.tenantGroups);
+ multiTenantTestUtils.testWorkloadWithHandlers(properties, model, scenario.getName(),
+ numHandlers, settings.expectedTenantGroups, settings.expectedOpGroups);
+ }
+ }
+
+ private TestConfigAndExpectations getTestConfigAndExpectations(Scenario scenario, GeneratorType generatorType) {
+ TestConfigAndExpectations settings = new TestConfigAndExpectations();
+
+ switch (generatorType) {
+ case WEIGHTED:
+ settings.tenantGroups = scenario.getLoadProfile().getTenantDistribution();
+ settings.expectedOpGroups = scenario.getLoadProfile().getOpDistribution().size();
+ settings.expectedTenantGroups = scenario.getLoadProfile().getTenantDistribution().size();
+ default:
+ List<TenantGroup> tenantGroups = new ArrayList<>();
+ TenantGroup tg1 = new TenantGroup();
+ tg1.setId("tg1");
+ tg1.setNumTenants(10);
+ tg1.setWeight(100);
+ tenantGroups.add(tg1);
+ settings.tenantGroups = tenantGroups;
+ settings.expectedTenantGroups = 1;
+ settings.expectedOpGroups = scenario.getLoadProfile().getOpDistribution().size();;
+ break;
+ }
+ return settings;
+ }
+}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTableOperationBaseIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTableOperationBaseIT.java
deleted file mode 100644
index 89420ed..0000000
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantTableOperationBaseIT.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.phoenix.pherf.workload.mt.tenantoperation;
-
-import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
-import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
-import org.apache.phoenix.pherf.PherfConstants;
-import org.apache.phoenix.pherf.XMLConfigParserTest;
-import org.apache.phoenix.pherf.configuration.DataModel;
-import org.apache.phoenix.pherf.configuration.XMLConfigParser;
-import org.apache.phoenix.pherf.schema.SchemaReader;
-import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
-
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@Category(NeedsOwnMiniClusterTest.class)
-public class MultiTenantTableOperationBaseIT extends ParallelStatsDisabledIT {
-
- protected static final String matcherScenario = ".*scenario/.*test_tbl_workload.*xml";
- protected static final String matcherSchema = ".*datamodel/.*test_schema_tbl*.*sql";
-
- protected static PhoenixUtil util = PhoenixUtil.create(true);
- protected static Properties properties;
- protected static SchemaReader reader;
- protected static XMLConfigParser parser;
- protected static List<Path> resources;
-
- @BeforeClass public static synchronized void setUp() throws Exception {
- PherfConstants constants = PherfConstants.create();
- properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, false);
-
- PhoenixUtil.setZookeeper("localhost");
- reader = new SchemaReader(util, matcherSchema);
- parser = new XMLConfigParser(matcherScenario);
- reader.applySchema();
- resources = new ArrayList<>(reader.getResourceList());
-
- assertTrue("Could not pull list of schema files.", resources.size() > 0);
- assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
-
- }
-
- public DataModel readTestDataModel(String resourceName) throws Exception {
- URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
- assertNotNull(scenarioUrl);
- Path p = Paths.get(scenarioUrl.toURI());
- return XMLConfigParser.readDataModel(p);
- }
-
-}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantViewOperationBaseIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantViewOperationBaseIT.java
deleted file mode 100644
index ba71977..0000000
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/MultiTenantViewOperationBaseIT.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.phoenix.pherf.workload.mt.tenantoperation;
-
-import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
-import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
-import org.apache.phoenix.pherf.PherfConstants;
-import org.apache.phoenix.pherf.XMLConfigParserTest;
-import org.apache.phoenix.pherf.configuration.DataModel;
-import org.apache.phoenix.pherf.configuration.XMLConfigParser;
-import org.apache.phoenix.pherf.schema.SchemaReader;
-import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
-
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@Category(NeedsOwnMiniClusterTest.class)
-public class MultiTenantViewOperationBaseIT extends ParallelStatsDisabledIT {
- protected static final String matcherScenario = ".*scenario/.*test_mt_workload.*xml";
- protected static final String matcherSchema = ".*datamodel/.*test_schema_mt*.*sql";
-
- protected static PhoenixUtil util = PhoenixUtil.create(true);
- protected static Properties properties;
- protected static SchemaReader reader;
- protected static XMLConfigParser parser;
- protected static List<Path> resources;
-
- @BeforeClass public static synchronized void setUp() throws Exception {
- PherfConstants constants = PherfConstants.create();
- properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, false);
-
- PhoenixUtil.setZookeeper("localhost");
- reader = new SchemaReader(util, matcherSchema);
- parser = new XMLConfigParser(matcherScenario);
- reader.applySchema();
- resources = new ArrayList<>(reader.getResourceList());
-
- assertTrue("Could not pull list of schema files.", resources.size() > 0);
- assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
-
- }
-
- public DataModel readTestDataModel(String resourceName) throws Exception {
- URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
- assertNotNull(scenarioUrl);
- Path p = Paths.get(scenarioUrl.toURI());
- return XMLConfigParser.readDataModel(p);
- }
-
- @AfterClass public static synchronized void tearDown() throws Exception {
- dropNonSystemTables();
- }
-
-}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantTableOperationWorkloadIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantTableOperationWorkloadIT.java
deleted file mode 100644
index dc98848..0000000
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantTableOperationWorkloadIT.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.phoenix.pherf.workload.mt.tenantoperation;
-
-import com.lmax.disruptor.WorkHandler;
-import org.apache.phoenix.pherf.configuration.DataModel;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests focused on tenant tablee operations and their validations
- * Tests focused on tenant operation workloads {@link TenantOperationWorkload}
- * and workload handlers {@link WorkHandler}
- */
-public class TenantTableOperationWorkloadIT extends MultiTenantTableOperationBaseIT {
- private final MultiTenantTestUtils multiTenantTestUtils = new MultiTenantTestUtils();
- private final DataModel model;
-
- public TenantTableOperationWorkloadIT() throws Exception {
- model = readTestDataModel("/scenario/test_tbl_workload.xml");
- }
-
- @Test public void testVariousOperations() throws Exception {
- int expectedTenantGroups = 1;
- int expectedWriteOpGroups = 1;
- int expectedReadOpGroups = 2;
- multiTenantTestUtils.testVariousOperations(properties, model, "TEST_TABLE_WRITE",
- expectedTenantGroups, expectedWriteOpGroups);
- multiTenantTestUtils.testVariousOperations(properties, model, "TEST_TABLE_READ",
- expectedTenantGroups, expectedReadOpGroups);
- }
-
- @Test public void testWorkloadWithOneHandler() throws Exception {
- int expectedTenantGroups = 1;
- int expectedWriteOpGroups = 1;
- int expectedReadOpGroups = 2;
- multiTenantTestUtils.testWorkloadWithOneHandler(properties, model, "TEST_TABLE_WRITE",
- expectedTenantGroups, expectedWriteOpGroups);
- multiTenantTestUtils.testWorkloadWithOneHandler(properties, model, "TEST_TABLE_READ",
- expectedTenantGroups, expectedReadOpGroups);
- }
-
- @Test public void testWorkloadWithManyHandlers() throws Exception {
- int expectedTenantGroups = 1;
- int expectedWriteOpGroups = 1;
- int expectedReadOpGroups = 2;
- multiTenantTestUtils.testWorkloadWithManyHandlers(properties, model, "TEST_TABLE_WRITE",
- expectedTenantGroups, expectedWriteOpGroups);
- multiTenantTestUtils.testWorkloadWithManyHandlers(properties, model, "TEST_TABLE_READ",
- expectedTenantGroups, expectedReadOpGroups);
- }
-
-}
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantViewOperationWorkloadIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantViewOperationWorkloadIT.java
deleted file mode 100644
index 66bbe38..0000000
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantViewOperationWorkloadIT.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.phoenix.pherf.workload.mt.tenantoperation;
-
-import com.lmax.disruptor.WorkHandler;
-import org.apache.phoenix.pherf.configuration.DataModel;
-import org.junit.Test;
-
-/**
- * Tests focused on tenant view operations and their validations
- * Tests focused on tenant operation workloads {@link TenantOperationWorkload}
- * and workload handlers {@link WorkHandler}
- */
-public class TenantViewOperationWorkloadIT extends MultiTenantViewOperationBaseIT {
-
- private final MultiTenantTestUtils multiTenantTestUtils = new MultiTenantTestUtils();
- private final DataModel model;
-
- public TenantViewOperationWorkloadIT() throws Exception {
- model = readTestDataModel("/scenario/test_mt_workload.xml");
- }
-
- @Test public void testVariousOperations() throws Exception {
- int expectedTenantGroups = 3;
- int expectedOpGroups = 5;
- multiTenantTestUtils.testVariousOperations(properties, model, null,
- expectedTenantGroups, expectedOpGroups);
- }
-
- @Test public void testWorkloadWithOneHandler() throws Exception {
- int expectedTenantGroups = 3;
- int expectedOpGroups = 5;
- multiTenantTestUtils.testWorkloadWithOneHandler(properties, model, null,
- expectedTenantGroups, expectedOpGroups);
-
- }
-
- @Test public void testWorkloadWithManyHandlers() throws Exception {
- int expectedTenantGroups = 3;
- int expectedOpGroups = 5;
- multiTenantTestUtils.testWorkloadWithManyHandlers(properties, model, null,
- expectedTenantGroups, expectedOpGroups);
- }
-}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java
index 837dfd9..48eb0f3 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java
@@ -43,7 +43,7 @@ import org.apache.phoenix.pherf.schema.SchemaReader;
import org.apache.phoenix.pherf.util.GoogleChartGenerator;
import org.apache.phoenix.pherf.util.PhoenixUtil;
import org.apache.phoenix.pherf.util.ResourceList;
-import org.apache.phoenix.pherf.workload.mt.tenantoperation.TenantOperationWorkload;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantWorkload;
import org.apache.phoenix.pherf.workload.QueryExecutor;
import org.apache.phoenix.pherf.workload.Workload;
import org.apache.phoenix.pherf.workload.WorkloadExecutor;
@@ -70,6 +70,8 @@ public class Pherf {
"Pre-loads data according to specified configuration values.");
options.addOption("scenarioFile", true,
"Regex or file name for the Test Scenario configuration .xml file to use.");
+ options.addOption("scenarioName", true,
+ "Regex or scenario name from the Test Scenario configuration .xml file to use.");
options.addOption("drop", true, "Regex drop all tables with schema name as PHERF. "
+ "\nExample drop Event tables: -drop .*(EVENT).* Drop all: -drop .* or -drop all");
options.addOption("schemaFile", true,
@@ -105,6 +107,7 @@ public class Pherf {
private final String zookeeper;
private final String scenarioFile;
+ private final String scenarioName;
private final String schemaFile;
private final String queryHint;
private final Properties properties;
@@ -164,6 +167,8 @@ public class Pherf {
writeRuntimeResults = !command.hasOption("disableRuntimeResult");
scenarioFile =
command.hasOption("scenarioFile") ? command.getOptionValue("scenarioFile") : null;
+ scenarioName =
+ command.hasOption("scenarioName") ? command.getOptionValue("scenarioName") : null;
schemaFile = command.hasOption("schemaFile") ? command.getOptionValue("schemaFile") : null;
rowCountOverride = Integer.parseInt(command.getOptionValue("rowCountOverride", "0"));
generateStatistics = command.hasOption("stats") ? GeneratePhoenixStats.YES : GeneratePhoenixStats.NO;
@@ -266,8 +271,6 @@ public class Pherf {
new GoogleChartGenerator(compareResults, compareType).readAndRender();
return;
}
-
- XMLConfigParser parser = new XMLConfigParser(scenarioFile);
// Drop tables with PHERF schema and regex comparison
if (null != dropPherfTablesRegEx) {
@@ -277,12 +280,6 @@ public class Pherf {
phoenixUtil.deleteTables(dropPherfTablesRegEx);
}
- if (monitor) {
- monitorManager =
- new MonitorManager(Integer.parseInt(
- properties.getProperty("pherf.default.monitorFrequency")));
- workloadExecutor.add(monitorManager);
- }
if (applySchema) {
LOGGER.info("\nStarting to apply schema...");
@@ -294,6 +291,19 @@ public class Pherf {
reader.applySchema();
}
+ // If no scenario file specified then we are done.
+ if (scenarioFile == null) {
+ return;
+ }
+
+ XMLConfigParser parser = new XMLConfigParser(scenarioFile);
+ if (monitor) {
+ monitorManager =
+ new MonitorManager(Integer.parseInt(
+ properties.getProperty("pherf.default.monitorFrequency")));
+ workloadExecutor.add(monitorManager);
+ }
+
// Schema and Data Load
if (preLoadData || multiTenantWorkload) {
LOGGER.info("\nStarting Data Load...");
@@ -302,7 +312,10 @@ public class Pherf {
if (multiTenantWorkload) {
for (DataModel model : parser.getDataModels()) {
for (Scenario scenario : model.getScenarios()) {
- Workload workload = new TenantOperationWorkload(phoenixUtil,
+ if ((scenarioName != null) && (scenarioName.compareTo(scenario.getName()) != 0)) {
+ continue;
+ }
+ Workload workload = new MultiTenantWorkload(phoenixUtil,
model, scenario, properties);
newWorkloads.add(workload);
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java
index 2a7a9b9..c749d15 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java
@@ -78,6 +78,12 @@ public class PherfConstants {
public static final int MONITOR_FREQUENCY = 5000;
public static final String MONITOR_FILE_NAME = "STATS_MONITOR";
+ public static final String NUM_SEQUENTIAL_ITERATIONS_PROP_KEY = "pherf.mt.sequential.iterations";
+ public static final String NUM_SEQUENTIAL_EXECUTION_TYPE_PROP_KEY = "pherf.mt.sequential.type";
+ public static final String HANDLERS_PER_SCENARIO_PROP_KEY = "pherf.mt.handlers_per_scenario";
+ public static final String MT_HANDLER_START_RENDEZVOUS_PROP_KEY = "pherf.mt.handlers_start_rendezvous";
+ public static final String MT_HANDLER_RESULTS_RENDEZVOUS_PROP_KEY = "pherf.mt.handlers_results_rendezvous";
+
private PherfConstants() {
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Scenario.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Scenario.java
index 1bebbad..3834de5 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Scenario.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Scenario.java
@@ -45,6 +45,7 @@ public class Scenario {
private LoadProfile loadProfile = null;
private String name;
+ private String generatorName;
private String tenantId;
private List<Ddl> preScenarioDdls;
private List<Ddl> postScenarioDdls;
@@ -89,6 +90,20 @@ public class Scenario {
}
/**
+ * Generator name for a scenario
+ *
+ * @return
+ */
+ @XmlAttribute()
+ public String getGeneratorName() {
+ return generatorName;
+ }
+
+ public void setGeneratorName(String name) {
+ this.generatorName = name;
+ }
+
+ /**
* Row count for a table
*
* @return
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Upsert.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Upsert.java
index 810a742..b2a7766 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Upsert.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/configuration/Upsert.java
@@ -22,8 +22,6 @@ import org.apache.phoenix.pherf.rules.RulesApplier;
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/PhoenixUtil.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/PhoenixUtil.java
index 1b5ba33..fd53b97 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/PhoenixUtil.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/PhoenixUtil.java
@@ -19,6 +19,9 @@
package org.apache.phoenix.pherf.util;
import com.google.gson.Gson;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.phoenix.coprocessor.TaskRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.mapreduce.index.automation.PhoenixMRJobSubmitter;
import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.configuration.Column;
@@ -30,6 +33,7 @@ import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.result.DataLoadTimeSummary;
import org.apache.phoenix.pherf.rules.DataValue;
import org.apache.phoenix.pherf.rules.RulesApplier;
+import org.apache.phoenix.query.QueryServicesOptions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -258,6 +262,15 @@ public class PhoenixUtil {
}
}
+ public void dropChildView(RegionCoprocessorEnvironment taskRegionEnvironment, int depth) {
+ TaskRegionObserver.SelfHealingTask task =
+ new TaskRegionObserver.SelfHealingTask(
+ taskRegionEnvironment, QueryServicesOptions.DEFAULT_TASK_HANDLING_MAX_INTERVAL_MS);
+ for (int i = 0; i < depth; i++) {
+ task.run();
+ }
+ }
+
public ResultSet getTableMetaData(String schemaName, String tableName, Connection connection)
throws SQLException {
DatabaseMetaData dbmd = connection.getMetaData();
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/EventGenerator.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/EventGenerator.java
deleted file mode 100644
index c6ffeea..0000000
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/EventGenerator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.phoenix.pherf.workload.mt;
-
-/**
- * An interface that implementers can use to generate events that can be consumed by
- * @see {@link com.lmax.disruptor.WorkHandler} which provide event handling functionality for
- * a given event.
- *
- * @param <T>
- */
-public interface EventGenerator<T> {
- T next();
-}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
index d2c19e8..c8fa699 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
@@ -17,30 +17,65 @@
*/
package org.apache.phoenix.pherf.workload.mt;
-
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.Workload;
+import org.apache.phoenix.pherf.workload.mt.generators.LoadEventGenerator;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantLoadEventGeneratorFactory;
+import org.apache.phoenix.pherf.workload.mt.handlers.TenantOperationWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
import java.util.Properties;
+import java.util.concurrent.Callable;
-public interface MultiTenantWorkload {
- /**
- * Initializes and readies the processor for continuous queue based workloads
- */
- void start();
+/**
+ * This class creates workload for tenant based load profiles.
+ * It uses @see {@link TenantOperationFactory} in conjunction with
+ * @see {@link LoadEventGenerator} to generate the load events.
+ * It then publishes these events onto a RingBuffer based queue.
+ * The @see {@link TenantOperationWorkHandler} drains the events from the queue and executes them.
+ * Reference for RingBuffer based queue http://lmax-exchange.github.io/disruptor/
+ */
- /**
- * Stop the processor and cleans up the workload queues.
- */
- void stop();
+public class MultiTenantWorkload implements Workload {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MultiTenantWorkload.class);
+ private final TenantLoadEventGeneratorFactory evtGeneratorFactory
+ = new TenantLoadEventGeneratorFactory();
+ private final LoadEventGenerator<TenantOperationInfo> generator;
- PhoenixUtil getPhoenixUtil();
+ public MultiTenantWorkload(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ Properties properties) {
+ this.generator = evtGeneratorFactory.newLoadEventGenerator(phoenixUtil,
+ model, scenario, properties);
+ }
- Scenario getScenario();
+ public MultiTenantWorkload(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) throws Exception {
+ this.generator = evtGeneratorFactory.newLoadEventGenerator(phoenixUtil,
+ model, scenario, workHandlers, properties);
+ }
- DataModel getModel();
+ @Override public Callable<Void> execute() throws Exception {
+ return new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ generator.start();
+ return null;
+ }
+ };
+ }
- Properties getProperties();
+ @Override public void complete() {
+ try {
+ generator.stop();
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage());
+ }
+ }
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkload.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/BaseLoadEventGenerator.java
similarity index 50%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkload.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/BaseLoadEventGenerator.java
index dca2a38..0298055 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkload.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/BaseLoadEventGenerator.java
@@ -16,10 +16,8 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.generators;
-import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import com.lmax.disruptor.BlockingWaitStrategy;
import com.lmax.disruptor.EventFactory;
import com.lmax.disruptor.ExceptionHandler;
@@ -27,35 +25,44 @@ import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.WorkHandler;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.dsl.ProducerType;
+import org.apache.hadoop.hbase.util.Threads;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.Workload;
-import org.apache.phoenix.pherf.workload.mt.EventGenerator;
-import org.apache.phoenix.pherf.workload.mt.MultiTenantWorkload;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.apache.phoenix.pherf.workload.mt.handlers.TenantOperationWorkHandler;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
+import org.apache.phoenix.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.List;
import java.util.Properties;
-import java.util.concurrent.Callable;
/**
- * This class creates workload for tenant based load profiles.
- * It uses @see {@link TenantOperationFactory} in conjunction with
- * @see {@link TenantOperationEventGenerator} to generate the load events.
- * It then publishes these events onto a RingBuffer based queue.
- * The @see {@link TenantOperationWorkHandler} drains the events from the queue and executes them.
- * Reference for RingBuffer based queue http://lmax-exchange.github.io/disruptor/
+ * A base class for all load event generators.
*/
+public abstract class BaseLoadEventGenerator
+ implements LoadEventGenerator<TenantOperationInfo> {
+ protected static final int DEFAULT_NUM_HANDLER_PER_SCENARIO = 4;
+ protected static final int DEFAULT_BUFFER_SIZE = 8192;
+ protected static final Logger LOGGER = LoggerFactory.getLogger(
+ BaseLoadEventGenerator.class);
+
+ protected Disruptor<TenantOperationEvent> disruptor;
+ protected List<PherfWorkHandler> handlers;
+ protected final Properties properties;
+
+ protected final TenantOperationFactory operationFactory;
+ protected final ExceptionHandler exceptionHandler;
-public class TenantOperationWorkload implements MultiTenantWorkload, Workload {
- private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationWorkload.class);
- private static final int DEFAULT_NUM_HANDLER_PER_MODEL = 4;
- private static final int DEFAULT_BUFFER_SIZE = 8192;
- private static class ContinuousWorkloadExceptionHandler implements ExceptionHandler {
+ private static class WorkloadExceptionHandler implements ExceptionHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WorkloadExceptionHandler.class);
+
@Override public void handleEventException(Throwable ex, long sequence, Object event) {
LOGGER.error("Sequence=" + sequence + ", event=" + event, ex);
throw new RuntimeException(ex);
@@ -90,55 +97,68 @@ public class TenantOperationWorkload implements MultiTenantWorkload, Workload {
};
}
- private Disruptor<TenantOperationEvent> disruptor;
- private final Properties properties;
- private final TenantOperationFactory operationFactory;
- private final EventGenerator<TenantOperationInfo> generator;
- private final List<WorkHandler> handlers;
- private final ExceptionHandler exceptionHandler;
-
- public TenantOperationWorkload(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
- List<WorkHandler> workers, Properties properties) throws Exception {
- this(phoenixUtil, model, scenario, workers, new ContinuousWorkloadExceptionHandler(), properties);
+ public BaseLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workers, Properties properties) {
+ this(phoenixUtil, model, scenario, workers, new WorkloadExceptionHandler(), properties);
}
- public TenantOperationWorkload(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
- Properties properties) throws Exception {
-
- operationFactory = new TenantOperationFactory(phoenixUtil, model, scenario);
- this.properties = properties;
- this.handlers = Lists.newArrayListWithCapacity(DEFAULT_NUM_HANDLER_PER_MODEL);
- for (int i = 0; i < DEFAULT_NUM_HANDLER_PER_MODEL; i++) {
- String handlerId = String.format("%s.%d", InetAddress.getLocalHost().getHostName(), i+1);
- handlers.add(new TenantOperationWorkHandler(
- operationFactory,
- handlerId));
- }
- this.generator = new TenantOperationEventGenerator(operationFactory.getOperations(),
- model, scenario);
- this.exceptionHandler = new ContinuousWorkloadExceptionHandler();
+ public BaseLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model,
+ Scenario scenario, Properties properties) {
+ this(phoenixUtil, model, scenario, null, new WorkloadExceptionHandler(), properties);
}
- public TenantOperationWorkload(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
- List<WorkHandler> workers,
+ public BaseLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model,
+ Scenario scenario,
+ List<PherfWorkHandler> workers,
ExceptionHandler exceptionHandler,
- Properties properties) throws Exception {
+ Properties properties) {
+
operationFactory = new TenantOperationFactory(phoenixUtil, model, scenario);
+ if (scenario.getPhoenixProperties() != null) {
+ properties.putAll(scenario.getPhoenixProperties());
+ }
this.properties = properties;
- this.generator = new TenantOperationEventGenerator(operationFactory.getOperations(),
- model, scenario);
+
+ if (workers == null || workers.isEmpty()) {
+ workers = getWorkHandlers(properties);
+ }
this.handlers = workers;
this.exceptionHandler = exceptionHandler;
}
- @Override public void start() {
+ @Override public PhoenixUtil getPhoenixUtil() { return operationFactory.getPhoenixUtil(); }
+
+ @Override public Scenario getScenario() {
+ return operationFactory.getScenario();
+ }
+
+ @Override public DataModel getModel() {
+ return operationFactory.getModel();
+ }
+ @Override public Properties getProperties() {
+ return this.properties;
+ }
+
+ @Override public TenantOperationFactory getOperationFactory() {
+ return operationFactory;
+ }
+
+ @Override public void start() throws Exception {
Scenario scenario = operationFactory.getScenario();
String currentThreadName = Thread.currentThread().getName();
- disruptor = new Disruptor<TenantOperationEvent>(TenantOperationEvent.EVENT_FACTORY, DEFAULT_BUFFER_SIZE,
- new ThreadFactoryBuilder().setNameFormat(currentThreadName + "." + scenario.getName() ).build(),
+ int bufferSize = DEFAULT_BUFFER_SIZE;
+ if (properties.containsKey("pherf.mt.buffer_size_per_scenario")) {
+ bufferSize = Integer.parseInt((String)properties.get("pherf.mt.buffer_size_per_scenario"));
+ }
+
+ disruptor = new Disruptor<>(TenantOperationEvent.EVENT_FACTORY, bufferSize,
+ new ThreadFactoryBuilder()
+ .setNameFormat(currentThreadName + "." + scenario.getName())
+ .setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER)
+ .build(),
ProducerType.SINGLE, new BlockingWaitStrategy());
this.disruptor.setDefaultExceptionHandler(this.exceptionHandler);
@@ -146,7 +166,8 @@ public class TenantOperationWorkload implements MultiTenantWorkload, Workload {
RingBuffer<TenantOperationEvent> ringBuffer = this.disruptor.start();
long numOperations = scenario.getLoadProfile().getNumOperations();
while (numOperations > 0) {
- TenantOperationInfo sample = generator.next();
+ TenantOperationInfo sample = next();
+ operationFactory.initializeTenant(sample);
--numOperations;
// Publishers claim events in sequence
long sequence = ringBuffer.next();
@@ -154,39 +175,43 @@ public class TenantOperationWorkload implements MultiTenantWorkload, Workload {
event.setTenantOperationInfo(sample);
// make the event available to EventProcessors
ringBuffer.publish(sequence);
- LOGGER.debug(String.format("published : %s:%s:%d",
- scenario.getName(), scenario.getTableName(), numOperations));
+ LOGGER.info(String.format("published : %s:%s:%d, %d, %d",
+ scenario.getName(), scenario.getTableName(),
+ numOperations, ringBuffer.getCursor(), sequence));
}
}
- @Override public void stop() {
- this.disruptor.shutdown();
+ @Override public void stop() throws Exception {
+ // Wait for the handlers to finish the jobs
+ if (disruptor != null) {
+ disruptor.shutdown();
+ }
+
+ // TODO need to handle asynchronous result publishing
}
- @Override public PhoenixUtil getPhoenixUtil() { return operationFactory.getPhoenixUtil(); }
+ @Override public List<PherfWorkHandler> getWorkHandlers(Properties properties) {
- @Override public Scenario getScenario() {
- return operationFactory.getScenario();
- }
+ String handlerName = "";
+ try {
+ handlerName = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
- @Override public DataModel getModel() {
- return operationFactory.getModel();
+ int handlerCount = DEFAULT_NUM_HANDLER_PER_SCENARIO;
+ if (properties.containsKey("pherf.mt.handlers_per_scenario")) {
+ handlerCount = Integer.parseInt((String)properties.get("pherf.mt.handlers_per_scenario"));
+ }
+ List<PherfWorkHandler> workers = Lists.newArrayListWithCapacity(handlerCount);
+ for (int i = 0; i < handlerCount; i++) {
+ String handlerId = String.format("%s.%d", handlerName, i + 1);
+ workers.add(new TenantOperationWorkHandler(operationFactory, handlerId));
+ }
+ return workers;
}
- @Override public Properties getProperties() {
- return this.properties;
- }
+ abstract public TenantOperationInfo next();
- @Override public Callable<Void> execute() throws Exception {
- return new Callable<Void>() {
- @Override public Void call() throws Exception {
- start();
- return null;
- }
- };
- }
- @Override public void complete() {
- stop();
- }
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGenerator.java
similarity index 55%
copy from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
copy to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGenerator.java
index d2c19e8..61f8fe7 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGenerator.java
@@ -16,25 +16,35 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.generators;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import java.util.List;
import java.util.Properties;
-public interface MultiTenantWorkload {
+/**
+ * An interface that implementers can use to generate load events that can be consumed by
+ * @see {@link com.lmax.disruptor.WorkHandler} which provide event handling functionality for
+ * a given event.
+ *
+ * @param <T> load event object
+ */
+public interface LoadEventGenerator<T> {
/**
- * Initializes and readies the processor for continuous queue based workloads
+ * Initializes and readies the generator for queue based workloads
*/
- void start();
+ void start() throws Exception;
/**
- * Stop the processor and cleans up the workload queues.
+ * Stop the generator and waits for the queues to drain.
*/
- void stop();
-
+ void stop() throws Exception;
PhoenixUtil getPhoenixUtil();
@@ -43,4 +53,10 @@ public interface MultiTenantWorkload {
DataModel getModel();
Properties getProperties();
+
+ TenantOperationFactory getOperationFactory();
+
+ List<PherfWorkHandler> getWorkHandlers(Properties properties);
+
+ TenantOperationInfo next();
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGeneratorFactory.java
similarity index 57%
copy from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
copy to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGeneratorFactory.java
index d2c19e8..63e482c 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/MultiTenantWorkload.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/LoadEventGeneratorFactory.java
@@ -16,31 +16,28 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.generators;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import java.util.List;
import java.util.Properties;
-public interface MultiTenantWorkload {
- /**
- * Initializes and readies the processor for continuous queue based workloads
- */
- void start();
-
- /**
- * Stop the processor and cleans up the workload queues.
- */
- void stop();
-
-
- PhoenixUtil getPhoenixUtil();
-
- Scenario getScenario();
+/**
+ * An interface that factory implementers need to implement
+ * for creating various supported load generators {@link LoadEventGenerator}
+ * @param <T> load event object
+ */
+public interface LoadEventGeneratorFactory<T> {
+ LoadEventGenerator<T> newLoadEventGenerator(PhoenixUtil phoenixUtil,
+ DataModel model, Scenario scenario,
+ Properties properties) ;
- DataModel getModel();
+ LoadEventGenerator<T> newLoadEventGenerator(PhoenixUtil phoenixUtil,
+ DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) ;
- Properties getProperties();
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/SequentialLoadEventGenerator.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/SequentialLoadEventGenerator.java
new file mode 100644
index 0000000..78fc78d
--- /dev/null
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/SequentialLoadEventGenerator.java
@@ -0,0 +1,187 @@
+/*
+ * 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.phoenix.pherf.workload.mt.generators;
+
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.ExecutionType;
+import org.apache.phoenix.pherf.configuration.LoadProfile;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.handlers.RendezvousingWorkHandler;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
+import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
+import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * A load generator that generates tenant operation events in the order specified in the
+ * scenario file.
+ * The scenario file can also specify on how many iterations to be executed per operation,
+ * whether the iterations be run in parallel or serially.
+ */
+public class SequentialLoadEventGenerator extends BaseLoadEventGenerator {
+
+ private static class SequentialSampler {
+ private final LoadProfile loadProfile;
+ private final String modelName;
+ private final String scenarioName;
+ private final String tableName;
+ private long iteration;
+ private int opIndex;
+ private int numHandlers;
+
+ private final TenantGroup tenantGroup;
+ private final List<Operation> operationList;
+
+ public SequentialSampler(List<Operation> operationList, DataModel model,
+ Scenario scenario, Properties properties) {
+ this.modelName = model.getName();
+ this.scenarioName = scenario.getName();
+ this.tableName = scenario.getTableName();
+ this.loadProfile = scenario.getLoadProfile();
+ this.operationList = operationList;
+
+ // Track the individual tenant group with single tenant or global connection,
+ // so that given a generated sample we can use the supplied tenant.
+ // NOTE : Not sure if there is a case for multiple tenants in a uniform distribution.
+ // For now keeping it simple.
+ Preconditions.checkArgument(loadProfile.getTenantDistribution() != null,
+ "Tenant distribution cannot be null");
+ Preconditions.checkArgument(!loadProfile.getTenantDistribution().isEmpty(),
+ "Tenant group cannot be empty");
+ Preconditions.checkArgument(loadProfile.getTenantDistribution().size() == 1,
+ "Tenant group cannot be more than 1");
+ tenantGroup = loadProfile.getTenantDistribution().get(0);
+ }
+
+ public TenantOperationInfo nextSample() {
+ Operation op = operationList.get(opIndex % operationList.size());
+ String tenantGroupId = tenantGroup.getId();
+ String tenantIdPrefix = Strings
+ .padStart(tenantGroupId, loadProfile.getGroupIdLength(), 'x');
+ String formattedTenantId = String.format(loadProfile.getTenantIdFormat(),
+ tenantIdPrefix.substring(0, loadProfile.getGroupIdLength()), 1);
+ String paddedTenantId = Strings.padStart(formattedTenantId, loadProfile.getTenantIdLength(), 'x');
+ String tenantId = paddedTenantId.substring(0, loadProfile.getTenantIdLength());
+
+ TenantOperationInfo sample = new TenantOperationInfo(modelName, scenarioName, tableName,
+ tenantGroupId, op.getId(), tenantId, op);
+
+ iteration++;
+ if (iteration % numHandlers == 0) {
+ opIndex++;
+ }
+ return sample;
+ }
+
+ public int getNumHandlers() {
+ return numHandlers;
+ }
+
+ public void setNumHandlers(int handlers) {
+ numHandlers = handlers;
+ }
+
+ }
+
+ protected static final int DEFAULT_NUM_ITERATIONS = 1;
+ protected static final ExecutionType DEFAULT_EXECUTION_TYPE = ExecutionType.SERIAL;
+ private final SequentialSampler sampler;
+ private int numHandlers;
+ private int numIterations = DEFAULT_NUM_ITERATIONS;
+ private ExecutionType executionType = DEFAULT_EXECUTION_TYPE;
+
+ public SequentialLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ Properties properties) {
+ super(phoenixUtil, model, scenario, properties);
+ this.sampler = new SequentialSampler(operationFactory.getOperations(), model, scenario, properties);
+ this.sampler.setNumHandlers(this.numHandlers);
+ }
+
+ public SequentialLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) {
+ super(phoenixUtil, model, scenario, workHandlers, properties);
+ this.sampler = new SequentialSampler(operationFactory.getOperations(), model, scenario, properties);
+ this.sampler.setNumHandlers(this.numHandlers);
+ }
+
+ public List<PherfWorkHandler> getWorkHandlers(Properties properties) {
+
+ String handlerName = "";
+ try {
+ handlerName = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+
+ this.numHandlers = DEFAULT_NUM_HANDLER_PER_SCENARIO;
+ if (properties.containsKey(PherfConstants.HANDLERS_PER_SCENARIO_PROP_KEY)) {
+ this.numHandlers = Integer.parseInt((String)properties.get(PherfConstants.HANDLERS_PER_SCENARIO_PROP_KEY));
+ }
+
+ if (properties.containsKey(PherfConstants.NUM_SEQUENTIAL_ITERATIONS_PROP_KEY)) {
+ this.numIterations = Integer.parseInt((String)properties.get(PherfConstants.NUM_SEQUENTIAL_ITERATIONS_PROP_KEY));
+ }
+
+ if (properties.containsKey(PherfConstants.NUM_SEQUENTIAL_EXECUTION_TYPE_PROP_KEY)) {
+ this.executionType = ExecutionType.valueOf((String)properties.get(PherfConstants.NUM_SEQUENTIAL_EXECUTION_TYPE_PROP_KEY));
+ switch (executionType) {
+ case SERIAL:
+ this.numHandlers = DEFAULT_NUM_ITERATIONS;
+ break;
+ case PARALLEL:
+ this.numHandlers = numIterations;
+ break;
+ default:
+ // Just accepts the defaults, nothing to do here
+ }
+ }
+
+ Map<String, CyclicBarrier> rendezvousPoints = Maps.newHashMap();
+ CyclicBarrier startBarrier = new CyclicBarrier(numHandlers, new Runnable() {
+ @Override public void run() {
+ LOGGER.info("Rendezvoused for start of operation execution");
+ }
+ });
+ rendezvousPoints.put(PherfConstants.MT_HANDLER_START_RENDEZVOUS_PROP_KEY, startBarrier);
+
+ List<PherfWorkHandler> workers = Lists.newArrayListWithCapacity(numHandlers);
+ for (int i = 0; i < numHandlers; i++) {
+ String handlerId = String.format("%s.%d", handlerName, i + 1);
+ workers.add(new RendezvousingWorkHandler(operationFactory, handlerId,
+ rendezvousPoints));
+ }
+ return workers;
+ }
+
+ @Override public TenantOperationInfo next() {
+ return this.sampler.nextSample();
+ }
+}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantLoadEventGeneratorFactory.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantLoadEventGeneratorFactory.java
new file mode 100644
index 0000000..31c1033
--- /dev/null
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantLoadEventGeneratorFactory.java
@@ -0,0 +1,70 @@
+/*
+ * 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.phoenix.pherf.workload.mt.generators;
+
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * A factory class for creating various supported load generators {@link LoadEventGenerator}
+ */
+public class TenantLoadEventGeneratorFactory implements
+ LoadEventGeneratorFactory<TenantOperationInfo> {
+ public enum GeneratorType {
+ WEIGHTED, UNIFORM, SEQUENTIAL
+ }
+ @Override public LoadEventGenerator<TenantOperationInfo> newLoadEventGenerator(PhoenixUtil phoenixUtil,
+ DataModel model, Scenario scenario,
+ Properties properties) {
+ GeneratorType type = GeneratorType.valueOf(scenario.getGeneratorName());
+ switch (type) {
+ case WEIGHTED:
+ return new WeightedRandomLoadEventGenerator(phoenixUtil, model, scenario, properties);
+ case UNIFORM:
+ return new UniformDistributionLoadEventGenerator(phoenixUtil, model, scenario, properties);
+ case SEQUENTIAL:
+ return new SequentialLoadEventGenerator(phoenixUtil, model, scenario, properties);
+ default:
+ throw new IllegalArgumentException("Unknown generator type");
+ }
+ }
+
+ @Override public LoadEventGenerator<TenantOperationInfo> newLoadEventGenerator(PhoenixUtil phoenixUtil,
+ DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) {
+ GeneratorType type = GeneratorType.valueOf(scenario.getGeneratorName());
+ switch (type) {
+ case WEIGHTED:
+ return new WeightedRandomLoadEventGenerator(phoenixUtil, model, scenario, workHandlers, properties);
+ case UNIFORM:
+ return new UniformDistributionLoadEventGenerator(phoenixUtil, model, scenario, workHandlers, properties);
+ case SEQUENTIAL:
+ return new SequentialLoadEventGenerator(phoenixUtil, model, scenario, workHandlers, properties);
+ default:
+ throw new IllegalArgumentException("Unknown generator type");
+ }
+
+ }
+
+}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationInfo.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantOperationInfo.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationInfo.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantOperationInfo.java
index 2481dd1..3b862f3 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationInfo.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/TenantOperationInfo.java
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.generators;
-import org.apache.phoenix.pherf.workload.mt.Operation;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
/**
* Holds information on the tenant operation details.
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/UniformDistributionLoadEventGenerator.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/UniformDistributionLoadEventGenerator.java
new file mode 100644
index 0000000..15ccbb4
--- /dev/null
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/UniformDistributionLoadEventGenerator.java
@@ -0,0 +1,109 @@
+/*
+ * 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.phoenix.pherf.workload.mt.generators;
+
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.LoadProfile;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
+import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
+import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+
+/**
+ * A load generator that generates a uniform distribution of operations among the given tenant group.
+ */
+public class UniformDistributionLoadEventGenerator extends BaseLoadEventGenerator {
+
+ private static class UniformDistributionSampler {
+ private final LoadProfile loadProfile;
+ private final String modelName;
+ private final String scenarioName;
+ private final String tableName;
+ private final Random distribution;
+
+ private final TenantGroup tenantGroup;
+ private final List<Operation> operationList;
+
+ public UniformDistributionSampler(List<Operation> operationList, DataModel model,
+ Scenario scenario) {
+ this.modelName = model.getName();
+ this.scenarioName = scenario.getName();
+ this.tableName = scenario.getTableName();
+ this.loadProfile = scenario.getLoadProfile();
+ this.operationList = operationList;
+
+ // Track the individual tenant group with single tenant or global connection,
+ // so that given a generated sample we can use the supplied tenant.
+ // NOTE : Not sure if there is a case for multiple tenants in a uniform distribution.
+ // For now keeping it simple.
+ Preconditions.checkArgument(loadProfile.getTenantDistribution() != null,
+ "Tenant distribution cannot be null");
+ Preconditions.checkArgument(!loadProfile.getTenantDistribution().isEmpty(),
+ "Tenant group cannot be empty");
+ Preconditions.checkArgument(loadProfile.getTenantDistribution().size() == 1,
+ "Tenant group cannot be more than 1");
+ tenantGroup = loadProfile.getTenantDistribution().get(0);
+
+ this.distribution = new Random();
+ }
+
+ public TenantOperationInfo nextSample() {
+ int sampleIndex = this.distribution.nextInt(operationList.size());
+ Operation op = operationList.get(sampleIndex);
+
+ String tenantGroupId = tenantGroup.getId();
+ String tenantIdPrefix = Strings
+ .padStart(tenantGroupId, loadProfile.getGroupIdLength(), 'x');
+ String formattedTenantId = String.format(loadProfile.getTenantIdFormat(),
+ tenantIdPrefix.substring(0, loadProfile.getGroupIdLength()), 1);
+ String paddedTenantId = Strings.padStart(formattedTenantId, loadProfile.getTenantIdLength(), 'x');
+ String tenantId = paddedTenantId.substring(0, loadProfile.getTenantIdLength());
+
+ TenantOperationInfo sample = new TenantOperationInfo(modelName, scenarioName, tableName,
+ tenantGroupId, op.getId(), tenantId, op);
+ return sample;
+ }
+ }
+
+ private final UniformDistributionSampler sampler;
+
+
+ public UniformDistributionLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ Properties properties) {
+ super(phoenixUtil, model, scenario, properties);
+ this.sampler = new UniformDistributionSampler(operationFactory.getOperations(), model, scenario);
+ }
+
+ public UniformDistributionLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) {
+ super(phoenixUtil, model, scenario, workHandlers, properties);
+ this.sampler = new UniformDistributionSampler(operationFactory.getOperations(), model, scenario);
+ }
+
+
+ @Override public TenantOperationInfo next() {
+ return this.sampler.nextSample();
+ }
+}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGenerator.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/WeightedRandomLoadEventGenerator.java
similarity index 87%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGenerator.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/WeightedRandomLoadEventGenerator.java
index 942633a..5f366bc 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGenerator.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/generators/WeightedRandomLoadEventGenerator.java
@@ -16,22 +16,22 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.generators;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.handlers.PherfWorkHandler;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.util.Pair;
-import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.LoadProfile;
import org.apache.phoenix.pherf.configuration.OperationGroup;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.configuration.TenantGroup;
-import org.apache.phoenix.pherf.workload.mt.Operation;
-import org.apache.phoenix.pherf.workload.mt.EventGenerator;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
import java.util.List;
import java.util.Map;
@@ -40,10 +40,11 @@ import java.util.Random;
/**
* A perf load event generator based on the supplied load profile.
+ * The load profile enumerates the distribution of operation among the different tenant group
+ * which is used by the load generator to generate the operation events for the various tenants.
*/
-public class TenantOperationEventGenerator
- implements EventGenerator<TenantOperationInfo> {
+public class WeightedRandomLoadEventGenerator extends BaseLoadEventGenerator {
private static class WeightedRandomSampler {
private static String AUTO_WEIGHTED_OPERATION_ID = "xxxxxx";
@@ -165,18 +166,17 @@ public class TenantOperationEventGenerator
}
private final WeightedRandomSampler sampler;
- private final Properties properties;
- public TenantOperationEventGenerator(List<Operation> ops, DataModel model, Scenario scenario)
- throws Exception {
- this(ops, model, scenario,
- PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES, true));
+ public WeightedRandomLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ Properties properties) {
+ super(phoenixUtil, model, scenario, properties);
+ this.sampler = new WeightedRandomSampler(operationFactory.getOperations(), model, scenario);
}
- public TenantOperationEventGenerator(List<Operation> ops, DataModel model, Scenario scenario,
- Properties properties) {
- this.properties = properties;
- this.sampler = new WeightedRandomSampler(ops, model, scenario);
+ public WeightedRandomLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
+ List<PherfWorkHandler> workHandlers, Properties properties) {
+ super(phoenixUtil, model, scenario, workHandlers, properties);
+ this.sampler = new WeightedRandomSampler(operationFactory.getOperations(), model, scenario);
}
@Override public TenantOperationInfo next() {
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/PherfWorkHandler.java
similarity index 71%
copy from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java
copy to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/PherfWorkHandler.java
index e0a276c..fc82b2e 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/PherfWorkHandler.java
@@ -16,16 +16,14 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.handlers;
-import org.apache.phoenix.pherf.configuration.Ddl;
+import com.lmax.disruptor.WorkHandler;
+import org.apache.phoenix.pherf.result.ResultValue;
+import org.apache.phoenix.pherf.workload.mt.operations.OperationStats;
import java.util.List;
-/**
- * Defines a pre scenario operation.
- * @see {@link OperationType#PRE_RUN}
- */
-public interface PreScenarioOperation extends Operation {
- List<Ddl> getPreScenarioDdls();
+public interface PherfWorkHandler<T> extends WorkHandler<T> {
+ List<ResultValue<OperationStats>> getResults();
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/RendezvousingWorkHandler.java
similarity index 53%
copy from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java
copy to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/RendezvousingWorkHandler.java
index 0ae4273..c70e0db 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/RendezvousingWorkHandler.java
@@ -16,36 +16,49 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.handlers;
-import org.apache.phoenix.thirdparty.com.google.common.base.Function;
-import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import com.lmax.disruptor.LifecycleAware;
import com.lmax.disruptor.WorkHandler;
+import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.configuration.Scenario;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.tenantoperation.TenantOperationWorkload.TenantOperationEvent;
+import org.apache.phoenix.pherf.result.ResultValue;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantWorkload;
+import org.apache.phoenix.pherf.workload.mt.generators.BaseLoadEventGenerator.TenantOperationEvent;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
+import org.apache.phoenix.pherf.workload.mt.operations.OperationStats;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.apache.phoenix.thirdparty.com.google.common.base.Function;
+import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CyclicBarrier;
+
/**
- * A handler {@link WorkHandler} for
- * executing the operations {@link org.apache.phoenix.pherf.workload.mt.Operation}
+ * A handler {@link WorkHandler} for simple orchestrations using the supplied rendezvous points
+ * The handler will wait for the rendezvous to happen before executing the operations {@link Operation}
+ * The handlers as in the basic {@link TenantOperationWorkHandler} will pick up the operation events
* as and when they become available on the {@link com.lmax.disruptor.RingBuffer}
- * when published by the workload generator {@link TenantOperationWorkload}
+ * when published by the workload generator {@link MultiTenantWorkload}
*/
-public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEvent>,
+public class RendezvousingWorkHandler implements PherfWorkHandler<TenantOperationEvent>,
LifecycleAware {
- private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationWorkHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(RendezvousingWorkHandler.class);
private final String handlerId;
private final TenantOperationFactory operationFactory;
+ private final Map<String, CyclicBarrier> rendezvousPoints;
-
- public TenantOperationWorkHandler(TenantOperationFactory operationFactory,
- String handlerId) {
+ public RendezvousingWorkHandler(TenantOperationFactory operationFactory,
+ String handlerId, Map<String, CyclicBarrier> rendezvousPoints) {
this.handlerId = handlerId;
this.operationFactory = operationFactory;
+ this.rendezvousPoints = rendezvousPoints;
}
@Override
@@ -54,8 +67,19 @@ public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEv
TenantOperationInfo input = event.getTenantOperationInfo();
Supplier<Function<TenantOperationInfo, OperationStats>> opSupplier =
operationFactory.getOperationSupplier(input);
+
+ boolean startRendezvousEnabled = rendezvousPoints.containsKey(PherfConstants.MT_HANDLER_START_RENDEZVOUS_PROP_KEY);
+ if (startRendezvousEnabled) {
+ rendezvousPoints.get(PherfConstants.MT_HANDLER_START_RENDEZVOUS_PROP_KEY).await();
+ }
OperationStats stats = opSupplier.get().apply(input);
stats.setHandlerId(handlerId);
+
+ // TODO need to handle asynchronous result publishing
+ boolean resultsRendezvousEnabled = rendezvousPoints.containsKey(PherfConstants.MT_HANDLER_RESULTS_RENDEZVOUS_PROP_KEY);
+ if (resultsRendezvousEnabled) {
+ rendezvousPoints.get(PherfConstants.MT_HANDLER_RESULTS_RENDEZVOUS_PROP_KEY).await();
+ }
LOGGER.info(operationFactory.getPhoenixUtil().getGSON().toJson(stats));
}
@@ -72,4 +96,8 @@ public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEv
LOGGER.info(String.format("TenantOperationWorkHandler stopped for %s:%s",
scenario.getName(), scenario.getTableName()));
}
+
+ @Override public List<ResultValue<OperationStats>> getResults() {
+ return new ArrayList<>();
+ }
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/TenantOperationWorkHandler.java
similarity index 73%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/TenantOperationWorkHandler.java
index 0ae4273..b3c9824 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationWorkHandler.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/handlers/TenantOperationWorkHandler.java
@@ -16,32 +16,39 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.handlers;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantWorkload;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import com.lmax.disruptor.LifecycleAware;
import com.lmax.disruptor.WorkHandler;
import org.apache.phoenix.pherf.configuration.Scenario;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.tenantoperation.TenantOperationWorkload.TenantOperationEvent;
+import org.apache.phoenix.pherf.result.ResultValue;
+import org.apache.phoenix.pherf.workload.mt.operations.OperationStats;
+import org.apache.phoenix.pherf.workload.mt.generators.BaseLoadEventGenerator.TenantOperationEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* A handler {@link WorkHandler} for
- * executing the operations {@link org.apache.phoenix.pherf.workload.mt.Operation}
+ * executing the operations {@link Operation}
* as and when they become available on the {@link com.lmax.disruptor.RingBuffer}
- * when published by the workload generator {@link TenantOperationWorkload}
+ * when published by the workload generator {@link MultiTenantWorkload}
*/
-public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEvent>,
+public class TenantOperationWorkHandler implements PherfWorkHandler<TenantOperationEvent>,
LifecycleAware {
private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationWorkHandler.class);
private final String handlerId;
private final TenantOperationFactory operationFactory;
-
public TenantOperationWorkHandler(TenantOperationFactory operationFactory,
String handlerId) {
this.handlerId = handlerId;
@@ -56,6 +63,7 @@ public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEv
operationFactory.getOperationSupplier(input);
OperationStats stats = opSupplier.get().apply(input);
stats.setHandlerId(handlerId);
+ // TODO need to handle asynchronous result publishing
LOGGER.info(operationFactory.getPhoenixUtil().getGSON().toJson(stats));
}
@@ -72,4 +80,8 @@ public class TenantOperationWorkHandler implements WorkHandler<TenantOperationEv
LOGGER.info(String.format("TenantOperationWorkHandler stopped for %s:%s",
scenario.getName(), scenario.getTableName()));
}
+
+ @Override public List<ResultValue<OperationStats>> getResults() {
+ return new ArrayList<>();
+ }
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/BaseOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/BaseOperationSupplier.java
similarity index 87%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/BaseOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/BaseOperationSupplier.java
index cda4504..7ac2f41 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/BaseOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/BaseOperationSupplier.java
@@ -16,8 +16,9 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import org.apache.phoenix.pherf.configuration.DataModel;
@@ -25,12 +26,11 @@ import org.apache.phoenix.pherf.configuration.LoadProfile;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.rules.RulesApplier;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
/**
* An abstract base class for all OperationSuppliers
*/
-abstract class BaseOperationSupplier implements Supplier<Function<TenantOperationInfo, OperationStats>> {
+public abstract class BaseOperationSupplier implements Supplier<Function<TenantOperationInfo, OperationStats>> {
final PhoenixUtil phoenixUtil;
final DataModel model;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/IdleTimeOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperation.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/IdleTimeOperation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperation.java
index bc7762f..6dd9262 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/IdleTimeOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.IdleTime;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/IdleTimeOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperationSupplier.java
similarity index 92%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/IdleTimeOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperationSupplier.java
index c65f430..8bfca00 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/IdleTimeOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/IdleTimeOperationSupplier.java
@@ -16,15 +16,14 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.IdleTime;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.IdleTimeOperation;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
@@ -35,7 +34,7 @@ import java.util.concurrent.TimeUnit;
/**
* A supplier of {@link Function} that takes {@link IdleTimeOperation} as an input.
*/
-class IdleTimeOperationSupplier extends BaseOperationSupplier {
+public class IdleTimeOperationSupplier extends BaseOperationSupplier {
private static final Logger LOGGER = LoggerFactory.getLogger(IdleTimeOperationSupplier.class);
public IdleTimeOperationSupplier(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario) {
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/Operation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/Operation.java
similarity index 95%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/Operation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/Operation.java
index 8774ae5..6556784 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/Operation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/Operation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
/**
* An interface that defines the type of operation included in the load profile.
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/OperationStats.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/OperationStats.java
similarity index 63%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/OperationStats.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/OperationStats.java
index c032ba4..8e4a44d 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/OperationStats.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/OperationStats.java
@@ -16,10 +16,11 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.result.ResultValue;
-import org.apache.phoenix.pherf.workload.mt.tenantoperation.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.operations.Operation;
import java.util.ArrayList;
import java.util.List;
@@ -28,13 +29,7 @@ import java.util.List;
* Holds metrics + contextual info on the operation run.
*/
public class OperationStats {
- private final String modelName;
- private final String scenarioName;
- private final String tableName;
- private final String tenantId;
- private final String tenantGroup;
- private final String operationGroup;
- private final Operation.OperationType opType;
+ private final TenantOperationInfo input;
private String handlerId;
private final int status;
private final long rowCount;
@@ -47,37 +42,31 @@ public class OperationStats {
int status,
long rowCount,
long durationInMs) {
- this.modelName = input.getModelName();
- this.scenarioName = input.getScenarioName();
- this.tableName = input.getTableName();
- this.tenantId = input.getTenantId();
- this.tenantGroup = input.getTenantGroupId();
- this.operationGroup = input.getOperationGroupId();
- this.opType = input.getOperation().getType();
+ this.input = input;
this.startTime = startTime;
this.status = status;
this.rowCount = rowCount;
this.durationInMs = durationInMs;
}
- public String getModelName() { return modelName; }
+ public String getModelName() { return this.input.getModelName(); }
- public String getScenarioName() { return scenarioName; }
+ public String getScenarioName() { return this.input.getScenarioName(); }
- public String getTenantId() { return tenantId; }
+ public String getTenantId() { return this.input.getTenantId(); }
- public Operation.OperationType getOpType() { return opType; }
+ public Operation.OperationType getOpType() { return this.input.getOperation().getType(); }
public String getTableName() {
- return tableName;
+ return this.input.getTableName();
}
public String getTenantGroup() {
- return tenantGroup;
+ return this.input.getTenantGroupId();
}
public String getOperationGroup() {
- return operationGroup;
+ return this.input.getOperationGroupId();
}
public int getStatus() {
@@ -98,14 +87,14 @@ public class OperationStats {
public List<ResultValue> getCsvRepresentation() {
List<ResultValue> rowValues = new ArrayList<>();
- rowValues.add(new ResultValue(modelName));
- rowValues.add(new ResultValue(scenarioName));
- rowValues.add(new ResultValue(tableName));
- rowValues.add(new ResultValue(tenantId));
+ rowValues.add(new ResultValue(getModelName()));
+ rowValues.add(new ResultValue(getScenarioName()));
+ rowValues.add(new ResultValue(getTableName()));
+ rowValues.add(new ResultValue(getTenantId()));
rowValues.add(new ResultValue(handlerId));
- rowValues.add(new ResultValue(tenantGroup));
- rowValues.add(new ResultValue(operationGroup));
- rowValues.add(new ResultValue(opType.name()));
+ rowValues.add(new ResultValue(getTenantGroup()));
+ rowValues.add(new ResultValue(getOperationGroup()));
+ rowValues.add(new ResultValue(getOpType().name()));
rowValues.add(new ResultValue(String.valueOf(startTime)));
rowValues.add(new ResultValue(String.valueOf(status)));
rowValues.add(new ResultValue(String.valueOf(rowCount)));
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperation.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperation.java
index e0a276c..6494859 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/PreScenarioOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.Ddl;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/PreScenarioOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperationSupplier.java
similarity index 93%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/PreScenarioOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperationSupplier.java
index a323a36..94e20f5 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/PreScenarioOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/PreScenarioOperationSupplier.java
@@ -16,28 +16,26 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Ddl;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.PreScenarioOperation;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
-import java.sql.SQLException;
/**
* A supplier of {@link Function} that takes {@link PreScenarioOperation} as an input
*/
-class PreScenarioOperationSupplier extends BaseOperationSupplier {
+public class PreScenarioOperationSupplier extends BaseOperationSupplier {
private static final Logger LOGGER = LoggerFactory.getLogger(PreScenarioOperationSupplier.class);
public PreScenarioOperationSupplier(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario) {
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/QueryOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperation.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/QueryOperation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperation.java
index 8b7ee78..db32567 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/QueryOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.Query;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/QueryOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperationSupplier.java
similarity index 96%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/QueryOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperationSupplier.java
index e149661..10a54d9 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/QueryOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/QueryOperationSupplier.java
@@ -16,17 +16,16 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Query;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.QueryOperation;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactory.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/TenantOperationFactory.java
similarity index 83%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactory.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/TenantOperationFactory.java
index 818bc6b..f9e262e 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactory.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/TenantOperationFactory.java
@@ -16,9 +16,13 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
-import org.apache.phoenix.pherf.configuration.Column;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.pherf.workload.mt.generators.LoadEventGenerator;
+import org.apache.phoenix.pherf.workload.mt.MultiTenantWorkload;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.handlers.TenantOperationWorkHandler;
import org.apache.phoenix.thirdparty.com.google.common.base.Charsets;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
@@ -40,18 +44,13 @@ import org.apache.phoenix.pherf.configuration.UserDefined;
import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.rules.RulesApplier;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.EventGenerator;
-import org.apache.phoenix.pherf.workload.mt.IdleTimeOperation;
-import org.apache.phoenix.pherf.workload.mt.Operation;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.PreScenarioOperation;
-import org.apache.phoenix.pherf.workload.mt.UpsertOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.sql.SQLException;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.locks.ReadWriteLock;
+import java.util.Objects;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
@@ -60,10 +59,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
* for operations {@link Operation}
*
* Operations that need to be executed for a given {@link Scenario} and {@link DataModel}
- * are generated by {@link EventGenerator}
+ * are generated by {@link LoadEventGenerator}
*
* These operation events are then published on to the {@link com.lmax.disruptor.RingBuffer}
- * by the {@link TenantOperationWorkload} workload generator and
+ * by the {@link MultiTenantWorkload} workload generator and
* handled by the {@link com.lmax.disruptor.WorkHandler} for eg {@link TenantOperationWorkHandler}
*/
public class TenantOperationFactory {
@@ -84,6 +83,18 @@ public class TenantOperationFactory {
public String getViewName() {
return viewName;
}
+
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ TenantView that = (TenantView) o;
+ return getTenantId().equals(that.getTenantId()) && getViewName()
+ .equals(that.getViewName());
+ }
+
+ @Override public int hashCode() {
+ return Objects.hash(getTenantId(), getViewName());
+ }
}
private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationFactory.class);
private final PhoenixUtil phoenixUtil;
@@ -98,7 +109,7 @@ public class TenantOperationFactory {
Maps.newEnumMap(Operation.OperationType.class);
private final BloomFilter<TenantView> tenantsLoaded;
- private ReadWriteLock rwLock = new ReentrantReadWriteLock();
+ private final ReentrantReadWriteLock viewCreationLock = new ReentrantReadWriteLock();
public TenantOperationFactory(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario) {
this.phoenixUtil = phoenixUtil;
@@ -164,7 +175,7 @@ public class TenantOperationFactory {
}
// This holds the info whether the tenant view was created (initialized) or not.
- return BloomFilter.create(tenantViewFunnel, numTenants, 0.01);
+ return BloomFilter.create(tenantViewFunnel, numTenants, 0.0000001);
}
private List<Operation> getUpsertOperationsForScenario(Scenario scenario) {
@@ -192,7 +203,7 @@ public class TenantOperationFactory {
List<Operation> opList = Lists.newArrayList();
for (final QuerySet querySet : scenario.getQuerySet()) {
for (final Query query : querySet.getQuery()) {
- Operation queryOp = new org.apache.phoenix.pherf.workload.mt.QueryOperation() {
+ Operation queryOp = new QueryOperation() {
@Override public Query getQuery() {
return query;
}
@@ -234,7 +245,7 @@ public class TenantOperationFactory {
private List<Operation> getUDFOperationsForScenario(Scenario scenario) {
List<Operation> opList = Lists.newArrayList();
for (final UserDefined udf : scenario.getUdfs()) {
- Operation udfOperation = new org.apache.phoenix.pherf.workload.mt.UserDefinedOperation() {
+ Operation udfOperation = new UserDefinedOperation() {
@Override public UserDefined getUserFunction() {
return udf;
}
@@ -268,22 +279,29 @@ public class TenantOperationFactory {
return operationList;
}
- public Supplier<Function<TenantOperationInfo, OperationStats>> getOperationSupplier(
- final TenantOperationInfo input) {
+ public void initializeTenant(TenantOperationInfo input) throws Exception {
TenantView tenantView = new TenantView(input.getTenantId(), scenario.getTableName());
// Check if pre run ddls are needed.
- if (!tenantsLoaded.mightContain(tenantView)) {
- rwLock.writeLock().lock();
- try {
- if (!tenantsLoaded.mightContain(tenantView)) {
- executePreRunOpsForTenant(tenantView, input);
- tenantsLoaded.put(tenantView);
+ viewCreationLock.writeLock().lock();
+ try {
+ if (!tenantsLoaded.mightContain(tenantView)) {
+ executePreRunOpsForTenant(tenantView, input);
+ boolean updated = tenantsLoaded.put(tenantView);
+ if (updated) {
+ LOGGER.info(String.format("Successfully initialized tenant. [%s, %s] ",
+ tenantView.tenantId,
+ tenantView.viewName));
}
- } finally {
- rwLock.writeLock().unlock();
}
+ } finally {
+ viewCreationLock.writeLock().unlock();
}
+ }
+
+
+ public Supplier<Function<TenantOperationInfo, OperationStats>> getOperationSupplier(
+ final TenantOperationInfo input) throws Exception {
Supplier<Function<TenantOperationInfo, OperationStats>> opSupplier =
operationSuppliers.get(input.getOperation().getType());
@@ -293,7 +311,7 @@ public class TenantOperationFactory {
return opSupplier;
}
- private void executePreRunOpsForTenant(TenantView tenantView, TenantOperationInfo input) {
+ private void executePreRunOpsForTenant(TenantView tenantView, TenantOperationInfo input) throws Exception {
Supplier<Function<TenantOperationInfo, OperationStats>> preRunOpSupplier =
operationSuppliers.get(Operation.OperationType.PRE_RUN);
@@ -332,6 +350,14 @@ public class TenantOperationFactory {
LOGGER.error(String.format("Failed to initialize tenant. [%s, %s] ",
tenantView.tenantId,
tenantView.viewName), e);
+ if (e.getClass().isAssignableFrom(SQLException.class)) {
+ SQLException sqlException = (SQLException) e;
+ if (SQLExceptionCode.CONCURRENT_TABLE_MUTATION.getErrorCode() != sqlException.getErrorCode()) {
+ throw e;
+ }
+ } else {
+ throw e;
+ }
}
}
}
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UpsertOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperation.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UpsertOperation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperation.java
index cb6abd9..9c7d59b 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UpsertOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.Upsert;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UpsertOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperationSupplier.java
similarity index 97%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UpsertOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperationSupplier.java
index f7ff24a..6a85411 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UpsertOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UpsertOperationSupplier.java
@@ -16,17 +16,16 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.TenantGroup;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.pherf.configuration.Column;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.configuration.Upsert;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.UpsertOperation;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
@@ -43,7 +42,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* A supplier of {@link Function} that takes {@link UpsertOperation} as an input
*/
-class UpsertOperationSupplier extends BaseOperationSupplier {
+public class UpsertOperationSupplier extends BaseOperationSupplier {
private static final Logger LOGGER = LoggerFactory.getLogger(UpsertOperationSupplier.class);
private ReadWriteLock rwLock = new ReentrantReadWriteLock();
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UserDefinedOperation.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperation.java
similarity index 94%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UserDefinedOperation.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperation.java
index 04f4fd8..838666c 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/UserDefinedOperation.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperation.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt;
+package org.apache.phoenix.pherf.workload.mt.operations;
import org.apache.phoenix.pherf.configuration.UserDefined;
diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UserDefinedOperationSupplier.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperationSupplier.java
similarity index 88%
rename from phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UserDefinedOperationSupplier.java
rename to phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperationSupplier.java
index f1f650a..9cb552a 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/UserDefinedOperationSupplier.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/mt/operations/UserDefinedOperationSupplier.java
@@ -16,21 +16,20 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt.operations;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
-import org.apache.phoenix.pherf.workload.mt.OperationStats;
-import org.apache.phoenix.pherf.workload.mt.UserDefinedOperation;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.util.EnvironmentEdgeManager;
/**
* A supplier of {@link Function} that takes {@link UserDefinedOperation} as an input
*/
-class UserDefinedOperationSupplier extends BaseOperationSupplier {
+public class UserDefinedOperationSupplier extends BaseOperationSupplier {
public UserDefinedOperationSupplier(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario) {
super(phoenixUtil, model, scenario);
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java
index 78f50a6..b0d7340 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java
@@ -24,12 +24,25 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import org.apache.phoenix.pherf.rules.RulesApplier;
+import org.apache.phoenix.pherf.configuration.Column;
+import org.apache.phoenix.pherf.configuration.DataOverride;
+import org.apache.phoenix.pherf.configuration.DataSequence;
+import org.apache.phoenix.pherf.configuration.DataTypeMapping;
+import org.apache.phoenix.pherf.configuration.Ddl;
+import org.apache.phoenix.pherf.configuration.ExecutionType;
+import org.apache.phoenix.pherf.configuration.Query;
+import org.apache.phoenix.pherf.configuration.QuerySet;
+import org.apache.phoenix.pherf.configuration.WriteParams;
import org.apache.phoenix.thirdparty.com.google.common.collect.Sets;
-import org.apache.phoenix.pherf.configuration.*;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.LoadProfile;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.rules.DataValue;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantLoadEventGeneratorFactory;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -140,6 +153,15 @@ public class ConfigurationParserTest extends ResultBaseTest {
}
Scenario testScenarioWithLoadProfile = scenarioList.get(0);
+ Map<String, String> props = testScenarioWithLoadProfile.getPhoenixProperties();
+ assertEquals("Number of properties(size) not as expected: ",
+ 2, props.size());
+ TenantLoadEventGeneratorFactory.GeneratorType
+ type = TenantLoadEventGeneratorFactory.GeneratorType.valueOf(
+ testScenarioWithLoadProfile.getGeneratorName());
+ assertEquals("Unknown generator type: ",
+ TenantLoadEventGeneratorFactory.GeneratorType.UNIFORM, type);
+
LoadProfile loadProfile = testScenarioWithLoadProfile.getLoadProfile();
assertEquals("batch size not as expected: ",
1, loadProfile.getBatchSize());
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/PherfTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/PherfTest.java
index 6a24ced..b10593e 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/PherfTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/PherfTest.java
@@ -38,7 +38,7 @@ public class PherfTest {
@Test
public void testUnknownOption() {
- String[] args = {"-drop", "all", "-q", "-m","-bsOption"};
+ String[] args = {"-drop", "all", "-q", "-m","-unknownOption"};
// Makes sure that System.exit(1) is called.
exit.expectSystemExitWithStatus(1);
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/SequentialLoadEventGeneratorTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/SequentialLoadEventGeneratorTest.java
new file mode 100644
index 0000000..b8c4368
--- /dev/null
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/SequentialLoadEventGeneratorTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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.phoenix.pherf.workload.mt;
+
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.XMLConfigParserTest;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.LoadProfile;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.XMLConfigParser;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.SequentialLoadEventGenerator;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests the various sequential event generation outcomes based on scenario, model
+ * execution type and iterations
+ */
+public class SequentialLoadEventGeneratorTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ SequentialLoadEventGeneratorTest.class);
+
+ private enum TestOperationGroup {
+ upsertOp, queryOp1, queryOp2, queryOp3, queryOp4, queryOp5, queryOp6, queryOp7, idleOp, udfOp
+ }
+
+ private enum TestTenantGroup {
+ tg1
+ }
+
+ public DataModel readTestDataModel(String resourceName) throws Exception {
+ URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
+ assertNotNull(scenarioUrl);
+ Path p = Paths.get(scenarioUrl.toURI());
+ return XMLConfigParser.readDataModel(p);
+ }
+
+ @Test
+ public void testParallelExecutionWithOneHandler() throws Exception {
+ sequentialEventGeneration(1, true);
+ }
+
+ @Test
+ public void testParallelExecutionWithManyHandler() throws Exception {
+ sequentialEventGeneration(5, true);
+ }
+
+ @Test
+ public void testSerialExecutionWithOneHandler() throws Exception {
+ sequentialEventGeneration(1, false);
+ }
+
+ @Test
+ public void testSerialExecutionWithManyHandler() throws Exception {
+ sequentialEventGeneration(5, false);
+ }
+
+ public void sequentialEventGeneration(int numIterations, boolean parallel) throws Exception {
+ int numTenantGroups = 1;
+ int numOpGroups = 10;
+ double variancePercent = 0.00f; // 0 percent
+
+ PhoenixUtil pUtil = PhoenixUtil.create();
+ Properties properties = PherfConstants
+ .create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+ properties.setProperty(PherfConstants.NUM_SEQUENTIAL_ITERATIONS_PROP_KEY, String.valueOf(numIterations));
+ properties.setProperty(PherfConstants.NUM_SEQUENTIAL_EXECUTION_TYPE_PROP_KEY,
+ parallel ? "PARALLEL" : "SERIAL");
+
+ DataModel model = readTestDataModel("/scenario/test_evt_gen4.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ LOGGER.debug(String.format("Testing %s", scenario.getName()));
+ LoadProfile loadProfile = scenario.getLoadProfile();
+ assertEquals("tenant group size is not as expected: ",
+ numTenantGroups, loadProfile.getTenantDistribution().size());
+ assertEquals("operation group size is not as expected: ",
+ numOpGroups, loadProfile.getOpDistribution().size());
+ // Calculate the expected distribution.
+ double[][] expectedDistribution = new double[numOpGroups][numTenantGroups];
+ for (int r = 0; r < numOpGroups; r++) {
+ for (int c = 0; c < numTenantGroups; c++) {
+ expectedDistribution[r][c] = numIterations;
+ LOGGER.debug(String.format("Expected [%d,%d] = %f", r, c, expectedDistribution[r][c]));
+ }
+ }
+
+ SequentialLoadEventGenerator evtGen = new SequentialLoadEventGenerator(
+ pUtil, model, scenario, properties);
+
+ // Calculate the actual distribution.
+ double[][] distribution = new double[numOpGroups][numTenantGroups];
+ for (int i = 0; i < numIterations; i++) {
+ for (int r = 0; r < numOpGroups; r++) {
+ TenantOperationInfo info = evtGen.next();
+ int row = TestOperationGroup.valueOf(info.getOperationGroupId()).ordinal();
+ int col = TestTenantGroup.valueOf(info.getTenantGroupId()).ordinal();
+ distribution[row][col]++;
+ }
+ }
+
+ // Validate that the expected and actual distribution
+ // is within the margin of allowed variance.
+ for (int r = 0; r < numOpGroups; r++) {
+ for (int c = 0; c < numTenantGroups; c++) {
+ double allowedVariance = expectedDistribution[r][c] * variancePercent;
+ double diff = Math.abs(expectedDistribution[r][c] - distribution[r][c]);
+ boolean isAllowed = diff == allowedVariance;
+ LOGGER.debug(String.format("Actual[%d,%d] = %f, %f, %f",
+ r, c, distribution[r][c], diff, allowedVariance));
+ assertTrue(String.format("Difference is outside the allowed variance "
+ + "[expected = %f, actual = %f]", allowedVariance, diff), isAllowed);
+
+ }
+ }
+ }
+ }
+}
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactoryTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/TenantOperationFactoryTest.java
similarity index 81%
rename from phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactoryTest.java
rename to phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/TenantOperationFactoryTest.java
index eefee4e..5dd3935 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationFactoryTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/TenantOperationFactoryTest.java
@@ -16,8 +16,9 @@
* limitations under the License.
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt;
+import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.XMLConfigParserTest;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.LoadProfile;
@@ -25,6 +26,13 @@ import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.generators.WeightedRandomLoadEventGenerator;
+import org.apache.phoenix.pherf.workload.mt.operations.IdleTimeOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.QueryOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.TenantOperationFactory;
+import org.apache.phoenix.pherf.workload.mt.operations.UpsertOperationSupplier;
+import org.apache.phoenix.pherf.workload.mt.operations.UserDefinedOperationSupplier;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@@ -33,6 +41,7 @@ import org.slf4j.LoggerFactory;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -67,6 +76,9 @@ public class TenantOperationFactoryTest {
int numOperations = 10;
PhoenixUtil pUtil = PhoenixUtil.create();
+ Properties properties = PherfConstants
+ .create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+
DataModel model = readTestDataModel("/scenario/test_evt_gen1.xml");
for (Scenario scenario : model.getScenarios()) {
LOGGER.debug(String.format("Testing %s", scenario.getName()));
@@ -76,15 +88,15 @@ public class TenantOperationFactoryTest {
assertEquals("operation group size is not as expected: ",
numOpGroups, loadProfile.getOpDistribution().size());
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
+ WeightedRandomLoadEventGenerator evtGen = new WeightedRandomLoadEventGenerator(
+ pUtil, model, scenario, properties);
+ TenantOperationFactory opFactory = evtGen.getOperationFactory();
assertEquals("operation group size from the factory is not as expected: ",
numOpGroups, opFactory.getOperations().size());
for (int i = 0; i < numRuns; i++) {
int ops = numOperations;
loadProfile.setNumOperations(ops);
- TenantOperationEventGenerator evtGen = new TenantOperationEventGenerator(
- opFactory.getOperations(), model, scenario);
while (ops-- > 0) {
TenantOperationInfo info = evtGen.next();
switch (TestOperationGroup.valueOf(info.getOperationGroupId())) {
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/UniformDistributionLoadEventGeneratorTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/UniformDistributionLoadEventGeneratorTest.java
new file mode 100644
index 0000000..f3c048a
--- /dev/null
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/UniformDistributionLoadEventGeneratorTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.phoenix.pherf.workload.mt;
+
+import org.apache.phoenix.pherf.PherfConstants;
+import org.apache.phoenix.pherf.XMLConfigParserTest;
+import org.apache.phoenix.pherf.configuration.DataModel;
+import org.apache.phoenix.pherf.configuration.LoadProfile;
+import org.apache.phoenix.pherf.configuration.Scenario;
+import org.apache.phoenix.pherf.configuration.XMLConfigParser;
+import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.generators.UniformDistributionLoadEventGenerator;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests the various event generation outcomes based on scenario, model and load profile.
+ */
+public class UniformDistributionLoadEventGeneratorTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ UniformDistributionLoadEventGeneratorTest.class);
+
+ private enum TestOperationGroup {
+ upsertOp, queryOp1, queryOp2, queryOp3, queryOp4, queryOp5, queryOp6, queryOp7, idleOp, udfOp
+ }
+
+ private enum TestTenantGroup {
+ tg1
+ }
+
+ public DataModel readTestDataModel(String resourceName) throws Exception {
+ URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
+ assertNotNull(scenarioUrl);
+ Path p = Paths.get(scenarioUrl.toURI());
+ return XMLConfigParser.readDataModel(p);
+ }
+
+ /**
+ * Case : where no operations and tenant groups have zero weight
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testVariousEventGeneration() throws Exception {
+ int numRuns = 100;
+ int numOperations = 1000;
+ double normalizedOperations = (double) (numOperations * numRuns) / 10000.0f;
+ int numTenantGroups = 1;
+ int numOpGroups = 10;
+ double variancePercent = 0.05f; // 5 percent
+
+ PhoenixUtil pUtil = PhoenixUtil.create();
+ Properties properties = PherfConstants
+ .create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+
+ DataModel model = readTestDataModel("/scenario/test_evt_gen3.xml");
+ for (Scenario scenario : model.getScenarios()) {
+ LOGGER.debug(String.format("Testing %s", scenario.getName()));
+ LoadProfile loadProfile = scenario.getLoadProfile();
+ assertEquals("tenant group size is not as expected: ",
+ numTenantGroups, loadProfile.getTenantDistribution().size());
+ assertEquals("operation group size is not as expected: ",
+ numOpGroups, loadProfile.getOpDistribution().size());
+ // Calculate the expected distribution.
+ double[][] expectedDistribution = new double[numOpGroups][numTenantGroups];
+ int tenantWeight = 100;
+ int opWeight = 10;
+ for (int r = 0; r < numOpGroups; r++) {
+ for (int c = 0; c < numTenantGroups; c++) {
+ expectedDistribution[r][c] = normalizedOperations * (tenantWeight * opWeight);
+ LOGGER.debug(String.format("Expected [%d,%d] = %f", r, c, expectedDistribution[r][c]));
+ }
+ }
+
+ UniformDistributionLoadEventGenerator
+ evtGen = new UniformDistributionLoadEventGenerator(
+ pUtil, model, scenario, properties);
+
+ // Calculate the actual distribution.
+ double[][] distribution = new double[numOpGroups][numTenantGroups];
+ for (int i = 0; i < numRuns; i++) {
+ int ops = numOperations;
+ loadProfile.setNumOperations(ops);
+ while (ops-- > 0) {
+ TenantOperationInfo info = evtGen.next();
+ int row = TestOperationGroup.valueOf(info.getOperationGroupId()).ordinal();
+ int col = TestTenantGroup.valueOf(info.getTenantGroupId()).ordinal();
+ distribution[row][col]++;
+ }
+ }
+
+ // Validate that the expected and actual distribution
+ // is within the margin of allowed variance.
+ for (int r = 0; r < numOpGroups; r++) {
+ for (int c = 0; c < numTenantGroups; c++) {
+ double allowedVariance = expectedDistribution[r][c] * variancePercent;
+ double diff = Math.abs(expectedDistribution[r][c] - distribution[r][c]);
+ boolean isAllowed = diff < allowedVariance;
+ LOGGER.debug(String.format("Actual[%d,%d] = %f, %f, %f",
+ r, c, distribution[r][c], diff, allowedVariance));
+ assertTrue(String.format("Difference is outside the allowed variance "
+ + "[expected = %f, actual = %f]", allowedVariance, diff), isAllowed);
+
+ }
+ }
+ }
+ }
+}
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGeneratorTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/WeightedRandomLoadEventGeneratorTest.java
similarity index 89%
rename from phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGeneratorTest.java
rename to phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/WeightedRandomLoadEventGeneratorTest.java
index 9d48034..ddc01b3 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/tenantoperation/TenantOperationEventGeneratorTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/mt/WeightedRandomLoadEventGeneratorTest.java
@@ -17,14 +17,17 @@
*/
-package org.apache.phoenix.pherf.workload.mt.tenantoperation;
+package org.apache.phoenix.pherf.workload.mt;
+import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.XMLConfigParserTest;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.LoadProfile;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.apache.phoenix.pherf.workload.mt.generators.TenantOperationInfo;
+import org.apache.phoenix.pherf.workload.mt.generators.WeightedRandomLoadEventGenerator;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -40,8 +44,9 @@ import static org.junit.Assert.assertTrue;
/**
* Tests the various event generation outcomes based on scenario, model and load profile.
*/
-public class TenantOperationEventGeneratorTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationEventGeneratorTest.class);
+public class WeightedRandomLoadEventGeneratorTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ WeightedRandomLoadEventGeneratorTest.class);
private enum TestOperationGroup {
upsertOp, queryOp1, queryOp2, idleOp, udfOp
}
@@ -63,7 +68,7 @@ public class TenantOperationEventGeneratorTest {
/**
* Case : where no operations and tenant groups have zero weight
- * * @throws Exception
+ * @throws Exception
*/
@Test
public void testVariousEventGeneration() throws Exception {
@@ -74,6 +79,9 @@ public class TenantOperationEventGeneratorTest {
int numOpGroups = 5;
PhoenixUtil pUtil = PhoenixUtil.create();
+ Properties properties = PherfConstants
+ .create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+
DataModel model = readTestDataModel("/scenario/test_evt_gen1.xml");
for (Scenario scenario : model.getScenarios()) {
LOGGER.debug(String.format("Testing %s", scenario.getName()));
@@ -93,15 +101,14 @@ public class TenantOperationEventGeneratorTest {
}
}
- // Calculate the actual distribution.
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
+ WeightedRandomLoadEventGenerator evtGen = new WeightedRandomLoadEventGenerator(
+ pUtil, model, scenario, properties);
+ // Calculate the actual distribution.
double[][] distribution = new double[numOpGroups][numTenantGroups];
for (int i = 0; i < numRuns; i++) {
int ops = numOperations;
- scenario.getLoadProfile().setNumOperations(ops);
- TenantOperationEventGenerator evtGen = new TenantOperationEventGenerator(
- opFactory.getOperations(), model, scenario);
+ loadProfile.setNumOperations(ops);
while (ops-- > 0) {
TenantOperationInfo info = evtGen.next();
int row = TestOperationGroup.valueOf(info.getOperationGroupId()).ordinal();
@@ -118,13 +125,16 @@ public class TenantOperationEventGeneratorTest {
*/
@Test
public void testAutoAssignedPMFs() throws Exception {
- int numRuns = 10;
+ int numRuns = 50;
int numOperations = 100000;
double normalizedOperations = (double) (numOperations * numRuns) / 10000.0f;
int numTenantGroups = 3;
int numOpGroups = 11;
PhoenixUtil pUtil = PhoenixUtil.create();
+ Properties properties = PherfConstants
+ .create().getProperties(PherfConstants.PHERF_PROPERTIES, false);
+
DataModel model = readTestDataModel("/scenario/test_evt_gen2.xml");
for (Scenario scenario : model.getScenarios()) {
LOGGER.debug(String.format("Testing %s", scenario.getName()));
@@ -167,15 +177,14 @@ public class TenantOperationEventGeneratorTest {
}
}
- // Calculate the actual distribution.
- TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
+ WeightedRandomLoadEventGenerator evtGen = new WeightedRandomLoadEventGenerator(
+ pUtil, model, scenario, properties);
+ // Calculate the actual distribution.
double[][] distribution = new double[numOpGroups][numTenantGroups];
for (int i = 0; i < numRuns; i++) {
int ops = numOperations;
- scenario.getLoadProfile().setNumOperations(ops);
- TenantOperationEventGenerator evtGen = new TenantOperationEventGenerator(
- opFactory.getOperations(), model, scenario);
+ loadProfile.setNumOperations(ops);
while (ops-- > 0) {
TenantOperationInfo info = evtGen.next();
int row = TestOperationGroup2.valueOf(info.getOperationGroupId()).ordinal();
diff --git a/phoenix-pherf/src/test/resources/datamodel/test_schema_mt_base_table.sql b/phoenix-pherf/src/test/resources/datamodel/test_mt_schema_base_table.sql
similarity index 100%
rename from phoenix-pherf/src/test/resources/datamodel/test_schema_mt_base_table.sql
rename to phoenix-pherf/src/test/resources/datamodel/test_mt_schema_base_table.sql
diff --git a/phoenix-pherf/src/test/resources/datamodel/test_schema_mt_view1.sql b/phoenix-pherf/src/test/resources/datamodel/test_mt_schema_view1.sql
similarity index 100%
rename from phoenix-pherf/src/test/resources/datamodel/test_schema_mt_view1.sql
rename to phoenix-pherf/src/test/resources/datamodel/test_mt_schema_view1.sql
diff --git a/phoenix-pherf/src/test/resources/datamodel/test_schema_mt_view2.sql b/phoenix-pherf/src/test/resources/datamodel/test_mt_schema_view2.sql
similarity index 100%
rename from phoenix-pherf/src/test/resources/datamodel/test_schema_mt_view2.sql
rename to phoenix-pherf/src/test/resources/datamodel/test_mt_schema_view2.sql
diff --git a/phoenix-pherf/src/test/resources/datamodel/test_schema_tbl_simple.sql b/phoenix-pherf/src/test/resources/datamodel/test_tbl_schema_simple.sql
similarity index 100%
rename from phoenix-pherf/src/test/resources/datamodel/test_schema_tbl_simple.sql
rename to phoenix-pherf/src/test/resources/datamodel/test_tbl_schema_simple.sql
diff --git a/phoenix-pherf/src/test/resources/scenario/test_evt_gen1.xml b/phoenix-pherf/src/test/resources/scenario/test_evt_gen1.xml
index c2aace6..d8902bb 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_evt_gen1.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_evt_gen1.xml
@@ -28,11 +28,11 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.EVT_GEN1" name="EVT_GEN1">
+ <scenario tableName="PHERF.EVT_GEN1" name="EVT_GEN1" generatorName="WEIGHTED">
<loadProfile>
<batchSize>1</batchSize>
<numOperations>1000</numOperations>
- <!-- Case 1 : where some operations have zero weight -->
+ <!-- Case 1 : where no operations have zero weight -->
<tenantDistribution id="tg1" weight="10" numTenants="10"></tenantDistribution>
<tenantDistribution id="tg2" weight="10" numTenants="10"></tenantDistribution>
<tenantDistribution id="tg3" weight="80" numTenants="10"></tenantDistribution>
@@ -52,8 +52,8 @@
</upserts>
<querySet>
- <query id="queryOp1" statement="select count(*) from PHERF.Z11"/>
- <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.Z11"/>
+ <query id="queryOp1" statement="select count(*) from PHERF.EVT_GEN1"/>
+ <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.EVT_GEN1"/>
</querySet>
<idleTimes>
<idleTime id="idleOp" idleTime="50"></idleTime>
diff --git a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml b/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
index b153bbd..4278abd 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
@@ -28,7 +28,7 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.EVT_GEN2" name="EVT_GEN2">
+ <scenario tableName="PHERF.EVT_GEN2" name="EVT_GEN2" generatorName="WEIGHTED">
<loadProfile>
<batchSize>1</batchSize>
<numOperations>1000</numOperations>
@@ -39,12 +39,12 @@
<opDistribution id="upsertOp" weight="40"></opDistribution>
<opDistribution id="queryOp1" weight="10"></opDistribution>
<opDistribution id="queryOp2" weight="10"></opDistribution>
- <opDistribution id="queryOp3" weight="0"></opDistribution>
- <opDistribution id="queryOp4" weight="0"></opDistribution>
- <opDistribution id="queryOp5" weight="0"></opDistribution>
- <opDistribution id="queryOp6" weight="0"></opDistribution>
- <opDistribution id="queryOp7" weight="0"></opDistribution>
- <opDistribution id="queryOp8" weight="0"></opDistribution>
+ <opDistribution id="queryOp3"></opDistribution>
+ <opDistribution id="queryOp4"></opDistribution>
+ <opDistribution id="queryOp5"></opDistribution>
+ <opDistribution id="queryOp6"></opDistribution>
+ <opDistribution id="queryOp7"></opDistribution>
+ <opDistribution id="queryOp8"></opDistribution>
<opDistribution id="idleOp" weight="10"></opDistribution>
<opDistribution id="udfOp" weight="10"></opDistribution>
</loadProfile>
@@ -58,14 +58,14 @@
</upserts>
<querySet>
- <query id="queryOp1" statement="select count(*) from PHERF.Z11"/>
- <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.Z11"/>
- <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.Z11"/>
- <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.Z11"/>
- <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.Z11"/>
- <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.Z11"/>
- <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.Z11"/>
- <query id="queryOp8" statement="select sum(SOME_INT) +8 from PHERF.Z11"/>
+ <query id="queryOp1" statement="select count(*) from PHERF.EVT_GEN2"/>
+ <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.EVT_GEN2"/>
+ <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.EVT_GEN2"/>
+ <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.EVT_GEN2"/>
+ <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.EVT_GEN2"/>
+ <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.EVT_GEN2"/>
+ <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.EVT_GEN2"/>
+ <query id="queryOp8" statement="select sum(SOME_INT) +8 from PHERF.EVT_GEN2"/>
</querySet>
<idleTimes>
<idleTime id="idleOp" idleTime="50"></idleTime>
diff --git a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml b/phoenix-pherf/src/test/resources/scenario/test_evt_gen3.xml
similarity index 65%
copy from phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
copy to phoenix-pherf/src/test/resources/scenario/test_evt_gen3.xml
index b153bbd..eb55f5d 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_evt_gen3.xml
@@ -28,25 +28,22 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.EVT_GEN2" name="EVT_GEN2">
+ <scenario tableName="PHERF.EVT_GEN3" name="EVT_GEN3" generatorName="UNIFORM">
<loadProfile>
<batchSize>1</batchSize>
<numOperations>1000</numOperations>
<!-- Case 1 : where some operations have zero weight -->
- <tenantDistribution id="tg1" weight="10" numTenants="10"></tenantDistribution>
- <tenantDistribution id="tg2" weight="10" numTenants="10"></tenantDistribution>
- <tenantDistribution id="tg3" weight="80" numTenants="10"></tenantDistribution>
- <opDistribution id="upsertOp" weight="40"></opDistribution>
- <opDistribution id="queryOp1" weight="10"></opDistribution>
- <opDistribution id="queryOp2" weight="10"></opDistribution>
- <opDistribution id="queryOp3" weight="0"></opDistribution>
- <opDistribution id="queryOp4" weight="0"></opDistribution>
- <opDistribution id="queryOp5" weight="0"></opDistribution>
- <opDistribution id="queryOp6" weight="0"></opDistribution>
- <opDistribution id="queryOp7" weight="0"></opDistribution>
- <opDistribution id="queryOp8" weight="0"></opDistribution>
- <opDistribution id="idleOp" weight="10"></opDistribution>
- <opDistribution id="udfOp" weight="10"></opDistribution>
+ <tenantDistribution id="tg1" numTenants="1"></tenantDistribution>
+ <opDistribution id="upsertOp"></opDistribution>
+ <opDistribution id="queryOp1"></opDistribution>
+ <opDistribution id="queryOp2"></opDistribution>
+ <opDistribution id="queryOp3"></opDistribution>
+ <opDistribution id="queryOp4"></opDistribution>
+ <opDistribution id="queryOp5"></opDistribution>
+ <opDistribution id="queryOp6"></opDistribution>
+ <opDistribution id="queryOp7"></opDistribution>
+ <opDistribution id="idleOp"></opDistribution>
+ <opDistribution id="udfOp"></opDistribution>
</loadProfile>
<upserts>
<upsert id="upsertOp">
@@ -58,14 +55,13 @@
</upserts>
<querySet>
- <query id="queryOp1" statement="select count(*) from PHERF.Z11"/>
- <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.Z11"/>
- <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.Z11"/>
- <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.Z11"/>
- <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.Z11"/>
- <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.Z11"/>
- <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.Z11"/>
- <query id="queryOp8" statement="select sum(SOME_INT) +8 from PHERF.Z11"/>
+ <query id="queryOp1" statement="select count(*) from PHERF.EVT_GEN3"/>
+ <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.EVT_GEN3"/>
+ <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.EVT_GEN3"/>
+ <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.EVT_GEN3"/>
+ <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.EVT_GEN3"/>
+ <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.EVT_GEN3"/>
+ <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.EVT_GEN3"/>
</querySet>
<idleTimes>
<idleTime id="idleOp" idleTime="50"></idleTime>
diff --git a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml b/phoenix-pherf/src/test/resources/scenario/test_evt_gen4.xml
similarity index 65%
copy from phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
copy to phoenix-pherf/src/test/resources/scenario/test_evt_gen4.xml
index b153bbd..d947e90 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_evt_gen2.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_evt_gen4.xml
@@ -28,25 +28,22 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.EVT_GEN2" name="EVT_GEN2">
+ <scenario tableName="PHERF.EVT_GEN4" name="EVT_GEN4" generatorName="SEQUENTIAL">
<loadProfile>
<batchSize>1</batchSize>
<numOperations>1000</numOperations>
<!-- Case 1 : where some operations have zero weight -->
- <tenantDistribution id="tg1" weight="10" numTenants="10"></tenantDistribution>
- <tenantDistribution id="tg2" weight="10" numTenants="10"></tenantDistribution>
- <tenantDistribution id="tg3" weight="80" numTenants="10"></tenantDistribution>
- <opDistribution id="upsertOp" weight="40"></opDistribution>
- <opDistribution id="queryOp1" weight="10"></opDistribution>
- <opDistribution id="queryOp2" weight="10"></opDistribution>
- <opDistribution id="queryOp3" weight="0"></opDistribution>
- <opDistribution id="queryOp4" weight="0"></opDistribution>
- <opDistribution id="queryOp5" weight="0"></opDistribution>
- <opDistribution id="queryOp6" weight="0"></opDistribution>
- <opDistribution id="queryOp7" weight="0"></opDistribution>
- <opDistribution id="queryOp8" weight="0"></opDistribution>
- <opDistribution id="idleOp" weight="10"></opDistribution>
- <opDistribution id="udfOp" weight="10"></opDistribution>
+ <tenantDistribution id="tg1" numTenants="1"></tenantDistribution>
+ <opDistribution id="upsertOp"></opDistribution>
+ <opDistribution id="queryOp1"></opDistribution>
+ <opDistribution id="queryOp2"></opDistribution>
+ <opDistribution id="queryOp3"></opDistribution>
+ <opDistribution id="queryOp4"></opDistribution>
+ <opDistribution id="queryOp5"></opDistribution>
+ <opDistribution id="queryOp6"></opDistribution>
+ <opDistribution id="queryOp7"></opDistribution>
+ <opDistribution id="idleOp"></opDistribution>
+ <opDistribution id="udfOp"></opDistribution>
</loadProfile>
<upserts>
<upsert id="upsertOp">
@@ -58,14 +55,13 @@
</upserts>
<querySet>
- <query id="queryOp1" statement="select count(*) from PHERF.Z11"/>
- <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.Z11"/>
- <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.Z11"/>
- <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.Z11"/>
- <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.Z11"/>
- <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.Z11"/>
- <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.Z11"/>
- <query id="queryOp8" statement="select sum(SOME_INT) +8 from PHERF.Z11"/>
+ <query id="queryOp1" statement="select count(*) from PHERF.EVT_GEN3"/>
+ <query id="queryOp2" statement="select sum(SOME_INT) from PHERF.EVT_GEN3"/>
+ <query id="queryOp3" statement="select sum(SOME_INT) +3 from PHERF.EVT_GEN3"/>
+ <query id="queryOp4" statement="select sum(SOME_INT) +4 from PHERF.EVT_GEN3"/>
+ <query id="queryOp5" statement="select sum(SOME_INT) +5 from PHERF.EVT_GEN3"/>
+ <query id="queryOp6" statement="select sum(SOME_INT) +6 from PHERF.EVT_GEN3"/>
+ <query id="queryOp7" statement="select sum(SOME_INT) +7 from PHERF.EVT_GEN3"/>
</querySet>
<idleTimes>
<idleTime id="idleOp" idleTime="50"></idleTime>
diff --git a/phoenix-pherf/src/test/resources/scenario/test_mt_workload.xml b/phoenix-pherf/src/test/resources/scenario/test_mt_workload_template.xml
similarity index 85%
rename from phoenix-pherf/src/test/resources/scenario/test_mt_workload.xml
rename to phoenix-pherf/src/test/resources/scenario/test_mt_workload_template.xml
index af19eb0..01d066d 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_mt_workload.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_mt_workload_template.xml
@@ -90,19 +90,19 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.EVT_1" name="EVT_11">
+ <scenario tableName="PHERF.EVT_1" name="EVT_1" generatorName="WEIGHTED">
<loadProfile>
<batchSize>1</batchSize>
- <numOperations>100</numOperations>
+ <numOperations>10000</numOperations>
<!-- Case 1 : Upsert Operation test -->
- <tenantDistribution id="tg1" weight="50" numTenants="1"></tenantDistribution>
- <tenantDistribution id="tg2" weight="40" numTenants="9"></tenantDistribution>
- <tenantDistribution id="tg3" weight="10" numTenants="10"></tenantDistribution>
- <opDistribution id="upsertOp" weight="20"></opDistribution>
- <opDistribution id="queryOp1" weight="20"></opDistribution>
- <opDistribution id="queryOp2" weight="20"></opDistribution>
- <opDistribution id="idleOp" weight="20"></opDistribution>
- <opDistribution id="udfOp" weight="20"></opDistribution>
+ <tenantDistribution id="tg1" weight="10" numTenants="1"/>
+ <tenantDistribution id="tg2" weight="40" numTenants="9"/>
+ <tenantDistribution id="tg3" weight="50" numTenants="10"/>
+ <opDistribution id="upsertOp" weight="20"/>
+ <opDistribution id="queryOp1" weight="20"/>
+ <opDistribution id="queryOp2" weight="20"/>
+ <opDistribution id="idleOp" weight="20"/>
+ <opDistribution id="udfOp" weight="20"/>
</loadProfile>
<preScenarioDdls>
<ddl statement="CREATE VIEW IF NOT EXISTS PHERF.EVT_1 (ZID CHAR(15), TYPE VARCHAR) AS SELECT * FROM PHERF.TEST_GLOBAL_VIEW1" />
@@ -156,19 +156,19 @@
</udf>
</udfs>
</scenario>
- <scenario tableName="PHERF.EVT_2" name="EVT_21">
+ <scenario tableName="PHERF.EVT_2" name="EVT_21" generatorName="WEIGHTED">
<loadProfile>
<batchSize>1</batchSize>
- <numOperations>100</numOperations>
+ <numOperations>10000</numOperations>
<!-- Case 1 : Upsert Operation test -->
- <tenantDistribution id="tg1" weight="50" numTenants="1"></tenantDistribution>
- <tenantDistribution id="tg2" weight="40" numTenants="9"></tenantDistribution>
- <tenantDistribution id="tg3" weight="10" numTenants="10"></tenantDistribution>
- <opDistribution id="upsertOp" weight="20"></opDistribution>
- <opDistribution id="queryOp1" weight="20"></opDistribution>
- <opDistribution id="queryOp2" weight="20"></opDistribution>
- <opDistribution id="idleOp" weight="20"></opDistribution>
- <opDistribution id="udfOp" weight="20"></opDistribution>
+ <tenantDistribution id="tg1" weight="10" numTenants="1"/>
+ <tenantDistribution id="tg2" weight="40" numTenants="9"/>
+ <tenantDistribution id="tg3" weight="50" numTenants="10"/>
+ <opDistribution id="upsertOp" weight="20"/>
+ <opDistribution id="queryOp1" weight="20"/>
+ <opDistribution id="queryOp2" weight="20"/>
+ <opDistribution id="idleOp" weight="20"/>
+ <opDistribution id="udfOp" weight="20"/>
</loadProfile>
<preScenarioDdls>
<ddl statement="CREATE VIEW IF NOT EXISTS PHERF.EVT_2 (INT_ID INTEGER, TYPE VARCHAR) AS SELECT * FROM PHERF.TEST_GLOBAL_VIEW2" />
diff --git a/phoenix-pherf/src/test/resources/scenario/test_tbl_workload.xml b/phoenix-pherf/src/test/resources/scenario/test_tbl_workload_template.xml
similarity index 98%
rename from phoenix-pherf/src/test/resources/scenario/test_tbl_workload.xml
rename to phoenix-pherf/src/test/resources/scenario/test_tbl_workload_template.xml
index f266131..32c79de 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_tbl_workload.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_tbl_workload_template.xml
@@ -141,7 +141,7 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.TEST_MULTI_TENANT_TABLE" name="TEST_TABLE_WRITE">
+ <scenario tableName="PHERF.TEST_MULTI_TENANT_TABLE" name="TEST_TABLE_WRITE" generatorName="WEIGHTED">
<loadProfile>
<numOperations>1</numOperations>
<tenantDistribution useGlobalConnection="true"/>
@@ -152,7 +152,7 @@
<upsert id="upsertOp" useGlobalConnection="true" upsertGroup="write"/>
</upserts>
</scenario>
- <scenario tableName="PHERF.TEST_MULTI_TENANT_TABLE" name="TEST_TABLE_READ">
+ <scenario tableName="PHERF.TEST_MULTI_TENANT_TABLE" name="TEST_TABLE_READ" generatorName="WEIGHTED">
<loadProfile>
<numOperations>1</numOperations>
<tenantDistribution useGlobalConnection="true"/>
diff --git a/phoenix-pherf/src/test/resources/scenario/test_workload_with_load_profile.xml b/phoenix-pherf/src/test/resources/scenario/test_workload_with_load_profile.xml
index 3a1c710..c75e8d0 100644
--- a/phoenix-pherf/src/test/resources/scenario/test_workload_with_load_profile.xml
+++ b/phoenix-pherf/src/test/resources/scenario/test_workload_with_load_profile.xml
@@ -230,7 +230,17 @@
</column>
</datamapping>
<scenarios>
- <scenario tableName="PHERF.Z11" name="scenario_11">
+ <scenario tableName="PHERF.Z11" name="scenario_11" generatorName="UNIFORM">
+ <phoenixProperties>
+ <entry>
+ <key>pherf.mt.handlers_per_scenario</key>
+ <value>2</value>
+ </entry>
+ <entry>
+ <key>pherf.mt.uniform.benchmark_mode</key>
+ <value>true</value>
+ </entry>
+ </phoenixProperties>
<loadProfile>
<batchSize>1</batchSize>
<numOperations>1000</numOperations>