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 00:42:59 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 8bc4d4131 -> 394e7224a


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/394e7224
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/394e7224
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/394e7224

Branch: refs/heads/master
Commit: 394e7224a9727538e1c08e5dece7e502cbc8397d
Parents: 8bc4d41
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Jun 28 17:42:51 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jun 28 17:42:51 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/PerformanceEvaluation.java     |  7 ++-
 .../hadoop/hbase/TestPerformanceEvaluation.java | 45 ++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/394e7224/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 f673b83..0528975 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;
@@ -2139,7 +2140,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);
+        }
         if (opts.size != DEFAULT_OPTS.size &&
             opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) {
           throw new IllegalArgumentException(rows + " and " + size +

http://git-wip-us.apache.org/repos/asf/hbase/blob/394e7224/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 fd33fe3..f774742 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
@@ -25,6 +25,9 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.LinkedList;
 
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileSystem;
@@ -138,4 +141,46 @@ public class TestPerformanceEvaluation {
     double median = snapshot.getMedian();
     assertTrue(median != 0 && median != 1 && median != valueSize);
   }
+
+  @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);
+    }
+  }
 }
\ No newline at end of file


Mime
View raw message