From 66d1258aa3a8c48a6001f5ec9d8eaeb64415873e Mon Sep 17 00:00:00 2001 From: binlijin Date: Wed, 8 Jan 2020 19:01:22 +0800 Subject: [PATCH] HBASE-23651 Region balance throttling can be disabled (#991) Signed-off-by: Viraj Jasani Signed-off-by: Anoop Sam John --- .../org/apache/hadoop/hbase/master/HMaster.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index ceef6b59ebc..b5f19d85d67 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -1688,12 +1688,10 @@ public class HMaster extends HRegionServer implements MasterServices { * @return Maximum time we should run balancer for */ private int getMaxBalancingTime() { - int maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_MAX_BALANCING, -1); - if (maxBalancingTime == -1) { - // if max balancing time isn't set, defaulting it to period time - maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_PERIOD, - HConstants.DEFAULT_HBASE_BALANCER_PERIOD); - } + // if max balancing time isn't set, defaulting it to period time + int maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_MAX_BALANCING, + getConfiguration() + .getInt(HConstants.HBASE_BALANCER_PERIOD, HConstants.DEFAULT_HBASE_BALANCER_PERIOD)); return maxBalancingTime; } @@ -1860,11 +1858,14 @@ public class HMaster extends HRegionServer implements MasterServices { //rpCount records balance plans processed, does not care if a plan succeeds rpCount++; - balanceThrottling(balanceStartTime + rpCount * balanceInterval, maxRegionsInTransition, + if (this.maxBlancingTime > 0) { + balanceThrottling(balanceStartTime + rpCount * balanceInterval, maxRegionsInTransition, cutoffTime); + } // if performing next balance exceeds cutoff time, exit the loop - if (rpCount < plans.size() && System.currentTimeMillis() > cutoffTime) { + if (this.maxBlancingTime > 0 && rpCount < plans.size() + && System.currentTimeMillis() > cutoffTime) { // TODO: After balance, there should not be a cutoff time (keeping it as // a security net for now) LOG.debug("No more balancing till next balance run; maxBalanceTime="