hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-16122 PerformanceEvaluation should provide user friendly hint when client threads argument is missing (Konstantin Ryakhovskiy)
Date Wed, 29 Jun 2016 03:28:13 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 48492ec7f -> 96a24aede


HBASE-16122 PerformanceEvaluation should provide user friendly hint when client threads argument
is missing (Konstantin Ryakhovskiy)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/96a24aed
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/96a24aed
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/96a24aed

Branch: refs/heads/branch-1
Commit: 96a24aede7760974df7ea9e762e1d63d658abd55
Parents: 48492ec
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Jun 28 20:28:06 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jun 28 20:28:06 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/PerformanceEvaluation.java     |  7 ++-
 .../hadoop/hbase/TestPerformanceEvaluation.java | 49 +++++++++++++++++++-
 2 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/96a24aed/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
index aedfd1c..40ddc39 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
@@ -36,6 +36,7 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.Random;
 import java.util.TreeMap;
+import java.util.NoSuchElementException;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -2065,7 +2066,11 @@ public class PerformanceEvaluation extends Configured implements Tool
{
 
       if (isCommandClass(cmd)) {
         opts.cmdName = cmd;
-        opts.numClientThreads = Integer.parseInt(args.remove());
+        try {
+          opts.numClientThreads = Integer.parseInt(args.remove());
+        } catch (NoSuchElementException | NumberFormatException e) {
+          throw new IllegalArgumentException("Command " + cmd + " does not have threads number",
e);
+        }
         int rowsPerGB = getRowsPerGB(opts);
         if (opts.size != DEFAULT_OPTS.size &&
             opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/96a24aed/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
index 3414e0a..37f8a78 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
@@ -17,9 +17,12 @@
  */
 package org.apache.hadoop.hbase;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.io.IOException;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.LinkedList;
 
 import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.codehaus.jackson.JsonGenerationException;
@@ -42,4 +45,46 @@ public class TestPerformanceEvaluation {
         mapper.readValue(optionsString, PerformanceEvaluation.TestOptions.class);
     assertTrue(optionsDeserialized.isAutoFlush());
   }
-}
\ No newline at end of file
+
+  @Test
+  public void testParseOptsWithThreads() {
+    Queue<String> opts = new LinkedList<>();
+    String cmdName = "sequentialWrite";
+    int threads = 1;
+    opts.offer(cmdName);
+    opts.offer(String.valueOf(threads));
+    PerformanceEvaluation.TestOptions options = PerformanceEvaluation.parseOpts(opts);
+    assertNotNull(options);
+    assertNotNull(options.getCmdName());
+    assertEquals(cmdName, options.getCmdName());
+    assertEquals(threads, options.getNumClientThreads());
+  }
+
+  @Test
+  public void testParseOptsWrongThreads() {
+    Queue<String> opts = new LinkedList<>();
+    String cmdName = "sequentialWrite";
+    opts.offer(cmdName);
+    opts.offer("qq");
+    try {
+      PerformanceEvaluation.parseOpts(opts);
+    } catch (IllegalArgumentException e) {
+      System.out.println(e.getMessage());
+      assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
+      assertTrue(e.getCause() instanceof NumberFormatException);
+    }
+  }
+
+  @Test
+  public void testParseOptsNoThreads() {
+    Queue<String> opts = new LinkedList<>();
+    String cmdName = "sequentialWrite";
+    try {
+      PerformanceEvaluation.parseOpts(opts);
+    } catch (IllegalArgumentException e) {
+      System.out.println(e.getMessage());
+      assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
+      assertTrue(e.getCause() instanceof NoSuchElementException);
+    }
+  }
+}


Mime
View raw message