You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/11/08 19:36:09 UTC

[3/3] hbase git commit: HBASE-21373 (backport from HBASE-21338) Warn if balancer is an ill-fit for cluster size

HBASE-21373 (backport from HBASE-21338) Warn if balancer is an ill-fit for cluster size

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


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

Branch: refs/heads/branch-1.3
Commit: 6f53424f8111b41fada49454d3bfe141007d9104
Parents: f5495b7
Author: xcang <xc...@salesforce.com>
Authored: Fri Oct 26 20:55:22 2018 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Nov 8 11:00:59 2018 -0800

----------------------------------------------------------------------
 .../master/balancer/StochasticLoadBalancer.java | 26 ++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/6f53424f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index e87170c..d1d8fa3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -103,6 +103,8 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
       "hbase.master.balancer.stochastic.stepsPerRegion";
   protected static final String MAX_STEPS_KEY =
       "hbase.master.balancer.stochastic.maxSteps";
+  protected static final String RUN_MAX_STEPS_KEY =
+      "hbase.master.balancer.stochastic.runMaxSteps";
   protected static final String MAX_RUNNING_TIME_KEY =
       "hbase.master.balancer.stochastic.maxRunningTime";
   protected static final String KEEP_REGION_LOADS =
@@ -116,6 +118,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
 
   // values are defaults
   private int maxSteps = 1000000;
+  private boolean runMaxSteps = false;
   private int stepsPerRegion = 800;
   private long maxRunningTime = 30 * 1000 * 1; // 30 seconds.
   private int numRegionLoadsToRemember = 15;
@@ -160,6 +163,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
 
     stepsPerRegion = conf.getInt(STEPS_PER_REGION_KEY, stepsPerRegion);
     maxRunningTime = conf.getLong(MAX_RUNNING_TIME_KEY, maxRunningTime);
+    runMaxSteps = conf.getBoolean(RUN_MAX_STEPS_KEY, runMaxSteps);
 
     numRegionLoadsToRemember = conf.getInt(KEEP_REGION_LOADS, numRegionLoadsToRemember);
     isByTable = conf.getBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable);
@@ -322,8 +326,26 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
     double initCost = currentCost;
     double newCost = currentCost;
 
-    long computedMaxSteps = Math.min(this.maxSteps,
-        ((long)cluster.numRegions * (long)this.stepsPerRegion * (long)cluster.numServers));
+    long computedMaxSteps = 0;
+    if (runMaxSteps) {
+      computedMaxSteps = Math.max(this.maxSteps,
+          ((long)cluster.numRegions * (long)this.stepsPerRegion * (long)cluster.numServers));
+    } else {
+      long calculatedMaxSteps =
+          (long) cluster.numRegions * (long) this.stepsPerRegion * (long) cluster.numServers;
+      computedMaxSteps = Math.min(this.maxSteps, calculatedMaxSteps);
+      if (calculatedMaxSteps > maxSteps) {
+        LOG.warn(String.format("calculatedMaxSteps:%d for loadbalancer's stochastic walk is larger "
+                + "than maxSteps:%dß. Hence load balancing may not work well. Setting parameter "
+                + "\"hbase.master.balancer.stochastic.runMaxSteps\" to true to overcome this issue."
+                + "(This config change does not require service restart)", calculatedMaxSteps,
+            maxRunningTime));
+
+      }
+    }
+    LOG.info("start StochasticLoadBalancer.balancer, initCost=" + currentCost +
+        " computedMaxSteps: " + computedMaxSteps);
+
     // Perform a stochastic walk to see if we can get a good fit.
     long step;