You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by hu...@apache.org on 2021/10/22 16:47:59 UTC
[hbase] branch branch-2 updated: HBASE-26308 Sum of multiplier of
cost functions is not populated properly when we have a shortcut for
trigger (#3783)
This is an automated email from the ASF dual-hosted git repository.
huaxiangsun pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new f299d56 HBASE-26308 Sum of multiplier of cost functions is not populated properly when we have a shortcut for trigger (#3783)
f299d56 is described below
commit f299d569349c4d938c4ed60f67d6e06251ebc19d
Author: clarax <cl...@gmail.com>
AuthorDate: Fri Oct 22 09:46:58 2021 -0700
HBASE-26308 Sum of multiplier of cost functions is not populated properly when we have a shortcut for trigger (#3783)
---
.../master/balancer/StochasticLoadBalancer.java | 44 ++++++++++++----------
1 file changed, 25 insertions(+), 19 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 8c01dea..3dc7670 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
@@ -136,7 +136,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
private List<CandidateGenerator> candidateGenerators;
private List<CostFunction> costFunctions; // FindBugs: Wants this protected; IS2_INCONSISTENT_SYNC
// To save currently configed sum of multiplier. Defaulted at 1 for cases that carry high cost
- private float sumMultiplier = 1.0f;
+ private float sumMultiplier;
// to save and report costs to JMX
private double curOverallCost = 0d;
private double[] tempFunctionCosts;
@@ -267,10 +267,12 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
this.namedQueueRecorder = NamedQueueRecorder.getInstance(conf);
}
- LOG.info("Loaded config; maxSteps=" + maxSteps + ", runMaxSteps=" + runMaxSteps +
- ", stepsPerRegion=" + stepsPerRegion +
- ", maxRunningTime=" + maxRunningTime + ", isByTable=" + isByTable + ", CostFunctions=" +
- Arrays.toString(getCostFunctionNames()) + " etc.");
+ LOG.info(
+ "Loaded config; maxSteps=" + maxSteps + ", runMaxSteps=" + runMaxSteps +
+ ", stepsPerRegion=" + stepsPerRegion +
+ ", maxRunningTime=" + maxRunningTime + ", isByTable=" + isByTable +
+ ", CostFunctions=" + Arrays.toString(getCostFunctionNames()) +
+ " , sum of multiplier of cost functions = " + sumMultiplier + " etc.");
}
@Override
@@ -355,31 +357,24 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
return false;
}
if (areSomeRegionReplicasColocated(cluster)) {
- LOG.info("Running balancer because at least one server hosts replicas of the same region.");
+ LOG.info("Running balancer because at least one server hosts replicas of the same region." +
+ " function cost={}", functionCost());
return true;
}
if (idleRegionServerExist(cluster)){
- LOG.info("Running balancer because cluster has idle server(s).");
+ LOG.info("Running balancer because cluster has idle server(s)."+
+ " function cost={}", functionCost());
return true;
}
- sumMultiplier = 0.0f;
double total = 0.0;
for (CostFunction c : costFunctions) {
- float multiplier = c.getMultiplier();
- double cost = c.cost();
if (!c.isNeeded()) {
LOG.trace("{} not needed", c.getClass().getSimpleName());
continue;
}
- total += cost * multiplier;
- sumMultiplier += multiplier;
- }
- if (sumMultiplier <= 0) {
- LOG.error("At least one cost function needs a multiplier > 0. For example, set "
- + "hbase.master.balancer.stochastic.regionCountCost to a positive value or default");
- return false;
+ total += c.cost() * c.getMultiplier();
}
boolean balanced = (total / sumMultiplier < minCostNeedBalance);
@@ -467,6 +462,17 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
long startTime = EnvironmentEdgeManager.currentTime();
initCosts(cluster);
+ sumMultiplier = 0;
+ for (CostFunction c : costFunctions) {
+ if(c.isNeeded()) {
+ sumMultiplier += c.getMultiplier();
+ }
+ }
+ if (sumMultiplier <= 0) {
+ LOG.error("At least one cost function needs a multiplier > 0. For example, set "
+ + "hbase.master.balancer.stochastic.regionCountCost to a positive value or default");
+ return null;
+ }
double currentCost = computeCost(cluster, Double.MAX_VALUE);
curOverallCost = currentCost;
@@ -638,8 +644,8 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
builder.append(", ");
double cost = c.cost();
builder.append("imbalance=" + cost);
- if (cost < minCostNeedBalance) {
- builder.append(", balanced");
+ if (cost >= minCostNeedBalance) {
+ builder.append(", need balance");
}
} else {
builder.append("not needed");