You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gj...@apache.org on 2022/06/22 15:07:57 UTC
[phoenix] branch 5.1 updated: PHOENIX-6530 - changed the tenant id generation for uniform distribution load generator (#1453)
This is an automated email from the ASF dual-hosted git repository.
gjacoby pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.1 by this push:
new 0a6c28ff2d PHOENIX-6530 - changed the tenant id generation for uniform distribution load generator (#1453)
0a6c28ff2d is described below
commit 0a6c28ff2dc9b81d1cbb40cac66beb51597c21e6
Author: thrylokya <th...@gmail.com>
AuthorDate: Wed Jun 22 20:27:07 2022 +0530
PHOENIX-6530 - changed the tenant id generation for uniform distribution load generator (#1453)
Co-authored-by: Thrylokya Geereddy <tg...@salesforce.com>
---
.../UniformDistributionLoadEventGenerator.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
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
index 15ccbb4e80..3dac8bb3c5 100644
--- 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
@@ -37,6 +37,10 @@ import java.util.Random;
public class UniformDistributionLoadEventGenerator extends BaseLoadEventGenerator {
private static class UniformDistributionSampler {
+
+ private final Random RANDOM = new Random();
+
+
private final LoadProfile loadProfile;
private final String modelName;
private final String scenarioName;
@@ -47,7 +51,7 @@ public class UniformDistributionLoadEventGenerator extends BaseLoadEventGenerato
private final List<Operation> operationList;
public UniformDistributionSampler(List<Operation> operationList, DataModel model,
- Scenario scenario) {
+ Scenario scenario) {
this.modelName = model.getName();
this.scenarioName = scenario.getName();
this.tableName = scenario.getTableName();
@@ -72,12 +76,19 @@ public class UniformDistributionLoadEventGenerator extends BaseLoadEventGenerato
public TenantOperationInfo nextSample() {
int sampleIndex = this.distribution.nextInt(operationList.size());
Operation op = operationList.get(sampleIndex);
+ int numTenants = 1;
+
+ if(tenantGroup.getNumTenants() != 0){
+ numTenants = tenantGroup.getNumTenants();
+ }
String tenantGroupId = tenantGroup.getId();
String tenantIdPrefix = Strings
.padStart(tenantGroupId, loadProfile.getGroupIdLength(), 'x');
+
String formattedTenantId = String.format(loadProfile.getTenantIdFormat(),
- tenantIdPrefix.substring(0, loadProfile.getGroupIdLength()), 1);
+ tenantIdPrefix.substring(0, loadProfile.getGroupIdLength()), RANDOM.nextInt(numTenants));
+
String paddedTenantId = Strings.padStart(formattedTenantId, loadProfile.getTenantIdLength(), 'x');
String tenantId = paddedTenantId.substring(0, loadProfile.getTenantIdLength());
@@ -91,13 +102,13 @@ public class UniformDistributionLoadEventGenerator extends BaseLoadEventGenerato
public UniformDistributionLoadEventGenerator(PhoenixUtil phoenixUtil, DataModel model, Scenario scenario,
- Properties properties) {
+ 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) {
+ List<PherfWorkHandler> workHandlers, Properties properties) {
super(phoenixUtil, model, scenario, workHandlers, properties);
this.sampler = new UniformDistributionSampler(operationFactory.getOperations(), model, scenario);
}