You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2020/06/09 06:12:51 UTC
[hbase] branch branch-2 updated: HBASE-24340 PerformanceEvaluation
options should not mandate any specific order
This is an automated email from the ASF dual-hosted git repository.
anoopsamjohn pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new e5ec59b HBASE-24340 PerformanceEvaluation options should not mandate any specific order
e5ec59b is described below
commit e5ec59ba2ccb451409489f6662ea4f9705cdc3e2
Author: Sambit Mohapatra <mo...@live.com>
AuthorDate: Mon Jun 8 23:02:39 2020 -0700
HBASE-24340 PerformanceEvaluation options should not mandate any specific order
Signed-off-by Anoop Sam John <an...@apache.org>
---
.../apache/hadoop/hbase/PerformanceEvaluation.java | 41 ++++++------
.../hadoop/hbase/TestPerformanceEvaluation.java | 77 +++++++++++++++++++++-
2 files changed, 95 insertions(+), 23 deletions(-)
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
index 2e2f2b5..9ff428f 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
@@ -2606,29 +2606,18 @@ public class PerformanceEvaluation extends Configured implements Tool {
final String autoFlush = "--autoFlush=";
if (cmd.startsWith(autoFlush)) {
opts.autoFlush = Boolean.parseBoolean(cmd.substring(autoFlush.length()));
- if (!opts.autoFlush && opts.multiPut > 0) {
- throw new IllegalArgumentException("autoFlush must be true when multiPut is more than 0");
- }
continue;
}
final String onceCon = "--oneCon=";
if (cmd.startsWith(onceCon)) {
opts.oneCon = Boolean.parseBoolean(cmd.substring(onceCon.length()));
- if (opts.oneCon && opts.connCount > 1) {
- throw new IllegalArgumentException("oneCon is set to true, "
- + "connCount should not bigger than 1");
- }
continue;
}
final String connCount = "--connCount=";
if (cmd.startsWith(connCount)) {
opts.connCount = Integer.parseInt(cmd.substring(connCount.length()));
- if (opts.oneCon && opts.connCount > 1) {
- throw new IllegalArgumentException("oneCon is set to true, "
- + "connCount should not bigger than 1");
- }
continue;
}
@@ -2647,9 +2636,6 @@ public class PerformanceEvaluation extends Configured implements Tool {
final String multiPut = "--multiPut=";
if (cmd.startsWith(multiPut)) {
opts.multiPut = Integer.parseInt(cmd.substring(multiPut.length()));
- if (!opts.autoFlush && opts.multiPut > 0) {
- throw new IllegalArgumentException("autoFlush must be true when multiPut is more than 0");
- }
continue;
}
@@ -2723,18 +2709,12 @@ public class PerformanceEvaluation extends Configured implements Tool {
final String valueRandom = "--valueRandom";
if (cmd.startsWith(valueRandom)) {
opts.valueRandom = true;
- if (opts.valueZipf) {
- throw new IllegalStateException("Either valueZipf or valueRandom but not both");
- }
continue;
}
final String valueZipf = "--valueZipf";
if (cmd.startsWith(valueZipf)) {
opts.valueZipf = true;
- if (opts.valueRandom) {
- throw new IllegalStateException("Either valueZipf or valueRandom but not both");
- }
continue;
}
@@ -2800,6 +2780,8 @@ public class PerformanceEvaluation extends Configured implements Tool {
continue;
}
+ validateParsedOpts(opts);
+
if (isCommandClass(cmd)) {
opts.cmdName = cmd;
try {
@@ -2821,6 +2803,25 @@ public class PerformanceEvaluation extends Configured implements Tool {
return opts;
}
+ /**
+ * Validates opts after all the opts are parsed, so that caller need not to maintain order of opts
+ */
+ private static void validateParsedOpts(TestOptions opts) {
+
+ if (!opts.autoFlush && opts.multiPut > 0) {
+ throw new IllegalArgumentException("autoFlush must be true when multiPut is more than 0");
+ }
+
+ if (opts.oneCon && opts.connCount > 1) {
+ throw new IllegalArgumentException("oneCon is set to true, "
+ + "connCount should not bigger than 1");
+ }
+
+ if (opts.valueZipf && opts.valueRandom) {
+ throw new IllegalStateException("Either valueZipf or valueRandom but not both");
+ }
+ }
+
static TestOptions calculateRowsAndSize(final TestOptions opts) {
int rowsPerGB = getRowsPerGB(opts);
if ((opts.getCmdName() != null
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
index 1940725..6e0d6a3 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
@@ -255,8 +255,14 @@ public class TestPerformanceEvaluation {
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
- ((LinkedList<String>) opts).offerFirst("--multiPut=10");
- ((LinkedList<String>) opts).offerFirst("--autoFlush=true");
+
+ //Re-create options
+ opts = new LinkedList<>();
+ opts.offer("--autoFlush=true");
+ opts.offer("--multiPut=10");
+ opts.offer(cmdName);
+ opts.offer("64");
+
options = PerformanceEvaluation.parseOpts(opts);
assertNotNull(options);
assertNotNull(options.getCmdName());
@@ -265,6 +271,36 @@ public class TestPerformanceEvaluation {
}
@Test
+ public void testParseOptsMultiPutsAndAutoFlushOrder() {
+ Queue<String> opts = new LinkedList<>();
+ String cmdName = "sequentialWrite";
+ String cmdMultiPut = "--multiPut=10";
+ String cmdAutoFlush = "--autoFlush=true";
+ opts.offer(cmdAutoFlush);
+ opts.offer(cmdMultiPut);
+ opts.offer(cmdName);
+ opts.offer("64");
+ PerformanceEvaluation.TestOptions options = null;
+ options = PerformanceEvaluation.parseOpts(opts);
+ assertNotNull(options);
+ assertEquals(true, options.autoFlush);
+ assertEquals(10, options.getMultiPut());
+
+ // Change the order of AutoFlush and Multiput
+ opts = new LinkedList<>();
+ opts.offer(cmdMultiPut);
+ opts.offer(cmdAutoFlush);
+ opts.offer(cmdName);
+ opts.offer("64");
+
+ options = null;
+ options = PerformanceEvaluation.parseOpts(opts);
+ assertNotNull(options);
+ assertEquals(10, options.getMultiPut());
+ assertEquals(true, options.autoFlush);
+ }
+
+ @Test
public void testParseOptsConnCount() {
Queue<String> opts = new LinkedList<>();
String cmdName = "sequentialWrite";
@@ -279,11 +315,46 @@ public class TestPerformanceEvaluation {
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
- ((LinkedList<String>) opts).offerFirst("--connCount=10");
+
+ opts = new LinkedList<>();
+ opts.offer("--connCount=10");
+ opts.offer(cmdName);
+ opts.offer("64");
+
options = PerformanceEvaluation.parseOpts(opts);
assertNotNull(options);
assertNotNull(options.getCmdName());
assertEquals(cmdName, options.getCmdName());
assertEquals(10, options.getConnCount());
}
+
+ @Test
+ public void testParseOptsValueRandom() {
+ Queue<String> opts = new LinkedList<>();
+ String cmdName = "sequentialWrite";
+ opts.offer("--valueRandom");
+ opts.offer("--valueZipf");
+ opts.offer(cmdName);
+ opts.offer("64");
+ PerformanceEvaluation.TestOptions options = null;
+ try {
+ options = PerformanceEvaluation.parseOpts(opts);
+ fail("should fail");
+ } catch (IllegalStateException e) {
+ System.out.println(e.getMessage());
+ }
+
+ opts = new LinkedList<>();
+ opts.offer("--valueRandom");
+ opts.offer(cmdName);
+ opts.offer("64");
+
+ options = PerformanceEvaluation.parseOpts(opts);
+
+ assertNotNull(options);
+ assertNotNull(options.getCmdName());
+ assertEquals(cmdName, options.getCmdName());
+ assertEquals(true, options.valueRandom);
+ }
+
}