hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [3/9] git commit: HBASE-11627 guard against divide by zero in RegionSplitter logging.
Date Fri, 15 Aug 2014 00:49:43 GMT
HBASE-11627 guard against divide by zero in RegionSplitter logging.

Adds a test for noop rolling splits that fails prior to the addition
of the guard.

Signed-off-by: Andrew Purtell <apurtell@apache.org>


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

Branch: refs/heads/master
Commit: e9fd2d5cae8c9b5045dd813a54a2ac4570317553
Parents: 9936b86
Author: Sean Busbey <busbey@apache.org>
Authored: Thu Aug 14 17:51:06 2014 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Thu Aug 14 17:51:06 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/util/RegionSplitter.java     | 6 ++++--
 .../java/org/apache/hadoop/hbase/util/TestRegionSplitter.java | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e9fd2d5c/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
index 8a2ffaa..f881d29 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
@@ -584,8 +584,10 @@ public class RegionSplitter {
       LOG.debug("TOTAL TIME = "
           + org.apache.hadoop.util.StringUtils.formatTime(tDiff));
       LOG.debug("Splits = " + splitCount);
-      LOG.debug("Avg Time / Split = "
-          + org.apache.hadoop.util.StringUtils.formatTime(tDiff / splitCount));
+      if (0 < splitCount) {
+        LOG.debug("Avg Time / Split = "
+            + org.apache.hadoop.util.StringUtils.formatTime(tDiff / splitCount));
+      }
 
       splitOut.close();
       if (table != null){

http://git-wip-us.apache.org/repos/asf/hbase/blob/e9fd2d5c/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
index 407be0d..878e109 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
@@ -282,6 +282,13 @@ public class TestRegionSplitter {
         verifyBounds(expectedBounds, tableName);
     }
 
+  @Test
+  public void noopRollingSplit() throws Exception {
+    final List<byte[]> expectedBounds = new ArrayList<byte[]>();
+    expectedBounds.add(ArrayUtils.EMPTY_BYTE_ARRAY);
+    rollingSplitAndVerify(TestRegionSplitter.class.getSimpleName(), "UniformSplit", expectedBounds);
+  }
+
     private void rollingSplitAndVerify(String tableName, String splitClass,
             List<byte[]> expectedBounds)  throws Exception {
         final Configuration conf = UTIL.getConfiguration();


Mime
View raw message