From 4bb84f7d0ce0159bda8412ff7b091cf011cad57a Mon Sep 17 00:00:00 2001 From: tedyu Date: Thu, 22 Sep 2016 07:33:34 -0700 Subject: [PATCH] HBASE-16675 Average region size may be incorrect when there is region whose RegionLoad cannot be retrieved --- .../hbase/master/normalizer/SimpleRegionNormalizer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java index fabd41ae7a8..a2a3f958479 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java @@ -136,16 +136,18 @@ public class SimpleRegionNormalizer implements RegionNormalizer { ", number of regions: " + tableRegions.size()); long totalSizeMb = 0; + int acutalRegionCnt = 0; for (int i = 0; i < tableRegions.size(); i++) { HRegionInfo hri = tableRegions.get(i); long regionSize = getRegionSize(hri); if (regionSize > 0) { + acutalRegionCnt++; totalSizeMb += regionSize; } } - double avgRegionSize = totalSizeMb / (double) tableRegions.size(); + double avgRegionSize = acutalRegionCnt == 0 ? 0 : totalSizeMb / (double) acutalRegionCnt; LOG.debug("Table " + table + ", total aggregated regions size: " + totalSizeMb); LOG.debug("Table " + table + ", average region size: " + avgRegionSize);