From e8a2e9f1f8d68b9d37dcfcabb6d2298f908a7422 Mon Sep 17 00:00:00 2001 From: dingwei Date: Thu, 24 Jun 2021 15:55:11 +0800 Subject: [PATCH 1/3] fix pe tool totalRows exceed maximum of int --- .../apache/hadoop/hbase/PerformanceEvaluation.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 77dd13d9ad72..8694802368cc 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 @@ -3031,12 +3031,24 @@ static TestOptions calculateRowsAndSize(final TestOptions opts) { && (opts.getCmdName().equals(RANDOM_READ) || opts.getCmdName().equals(RANDOM_SEEK_SCAN))) && opts.size != DEFAULT_OPTS.size && opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) { + if(Integer.MAX_VALUE / rowsPerGB < opts.size) { + throw new RuntimeException("totalRows is larger than maximum of int"); + } + opts.totalRows = (int) opts.size * rowsPerGB; } else if (opts.size != DEFAULT_OPTS.size) { // total size in GB specified + if(Integer.MAX_VALUE / rowsPerGB < opts.size) { + throw new RuntimeException("totalRows is larger than maximum of int"); + } + opts.totalRows = (int) opts.size * rowsPerGB; opts.perClientRunRows = opts.totalRows / opts.numClientThreads; } else { + if(Integer.MAX_VALUE / opts.numClientThreads < opts.perClientRunRows) { + throw new RuntimeException("totalRows is larger than maximum of int"); + } + opts.totalRows = opts.perClientRunRows * opts.numClientThreads; opts.size = opts.totalRows / rowsPerGB; } From a5f881a1ce3993a574f72aa87f28729b411fb187 Mon Sep 17 00:00:00 2001 From: dingwei Date: Tue, 6 Jul 2021 17:20:44 +0800 Subject: [PATCH 2/3] add some comment to the code --- .../java/org/apache/hadoop/hbase/PerformanceEvaluation.java | 2 ++ 1 file changed, 2 insertions(+) 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 8694802368cc..f35425e33094 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 @@ -3031,6 +3031,7 @@ static TestOptions calculateRowsAndSize(final TestOptions opts) { && (opts.getCmdName().equals(RANDOM_READ) || opts.getCmdName().equals(RANDOM_SEEK_SCAN))) && opts.size != DEFAULT_OPTS.size && opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) { + //if rowsPerGB * opts.size exceed the max of int, throw RuntimeException if(Integer.MAX_VALUE / rowsPerGB < opts.size) { throw new RuntimeException("totalRows is larger than maximum of int"); } @@ -3045,6 +3046,7 @@ static TestOptions calculateRowsAndSize(final TestOptions opts) { opts.totalRows = (int) opts.size * rowsPerGB; opts.perClientRunRows = opts.totalRows / opts.numClientThreads; } else { + //if opts.numClientThreads * opts.perClientRunRows exceed the max of int, throw RuntimeException if(Integer.MAX_VALUE / opts.numClientThreads < opts.perClientRunRows) { throw new RuntimeException("totalRows is larger than maximum of int"); } From a9d2084032114c35a99e6226a1566e453275f2c5 Mon Sep 17 00:00:00 2001 From: dingwei Date: Tue, 6 Jul 2021 17:24:56 +0800 Subject: [PATCH 3/3] add some comment to the code --- .../java/org/apache/hadoop/hbase/PerformanceEvaluation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 f35425e33094..cd1b00daa459 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 @@ -3031,11 +3031,11 @@ static TestOptions calculateRowsAndSize(final TestOptions opts) { && (opts.getCmdName().equals(RANDOM_READ) || opts.getCmdName().equals(RANDOM_SEEK_SCAN))) && opts.size != DEFAULT_OPTS.size && opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) { - //if rowsPerGB * opts.size exceed the max of int, throw RuntimeException + //if rowsPerGB * opts.size exceed the max of int, throw RuntimeException if(Integer.MAX_VALUE / rowsPerGB < opts.size) { throw new RuntimeException("totalRows is larger than maximum of int"); } - + opts.totalRows = (int) opts.size * rowsPerGB; } else if (opts.size != DEFAULT_OPTS.size) { // total size in GB specified @@ -3046,7 +3046,7 @@ static TestOptions calculateRowsAndSize(final TestOptions opts) { opts.totalRows = (int) opts.size * rowsPerGB; opts.perClientRunRows = opts.totalRows / opts.numClientThreads; } else { - //if opts.numClientThreads * opts.perClientRunRows exceed the max of int, throw RuntimeException + //if opts.numClientThreads * opts.perClientRunRows exceed the max of int, throw RuntimeException if(Integer.MAX_VALUE / opts.numClientThreads < opts.perClientRunRows) { throw new RuntimeException("totalRows is larger than maximum of int"); }