From 3c1b98fbe1e725161e3f226e48db0b304cee6222 Mon Sep 17 00:00:00 2001 From: Briana Augenreich Date: Tue, 15 Mar 2022 15:31:40 -0400 Subject: [PATCH 1/4] Hubspot Backport: HBASE-26798 improve balancer visibility --- .../balancer/StochasticLoadBalancer.java | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) 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 4a0dc6fe7d9b..a19e8b389858 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 @@ -132,6 +132,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { protected static final String COST_FUNCTIONS_COST_FUNCTIONS_KEY = "hbase.master.balancer.stochastic.additionalCostFunctions"; public static final String OVERALL_COST_FUNCTION_NAME = "Overall"; + public static final String WIGHTED_IMBALANCE_COST_NAME = "Imbalance"; protected static final Random RANDOM = new Random(System.currentTimeMillis()); private static final Logger LOG = LoggerFactory.getLogger(StochasticLoadBalancer.class); @@ -323,7 +324,7 @@ private void updateBalancerTableLoadInfo(TableName tableName, initCosts(cluster); curOverallCost = computeCost(cluster, Double.MAX_VALUE); System.arraycopy(tempFunctionCosts, 0, curFunctionCosts, 0, curFunctionCosts.length); - updateStochasticCosts(tableName, curOverallCost, curFunctionCosts); + updateStochasticCosts(tableName, curOverallCost, curOverallCost/sumMultiplier, curFunctionCosts); } @Override @@ -424,7 +425,7 @@ protected boolean needsBalance(TableName tableName, Cluster cluster) { @InterfaceAudience.Private Cluster.Action nextAction(Cluster cluster) { return candidateGenerators.get(RANDOM.nextInt(candidateGenerators.size())) - .generate(cluster); + .generate(cluster); } /** @@ -480,7 +481,7 @@ public synchronized List balanceTable(TableName tableName, Map balanceTable(TableName tableName, Map balanceTable(TableName tableName, Map