HBASE-25006 Make the cost functions optional for StochastoicBalancer
Closes #2386 Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
parent
e5ca9adc54
commit
fe776306d0
|
@ -205,19 +205,19 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
||||||
regionReplicaRackCostFunction = new RegionReplicaRackCostFunction(conf);
|
regionReplicaRackCostFunction = new RegionReplicaRackCostFunction(conf);
|
||||||
|
|
||||||
costFunctions = new ArrayList<>();
|
costFunctions = new ArrayList<>();
|
||||||
costFunctions.add(new RegionCountSkewCostFunction(conf));
|
addCostFunction(new RegionCountSkewCostFunction(conf));
|
||||||
costFunctions.add(new PrimaryRegionCountSkewCostFunction(conf));
|
addCostFunction(new PrimaryRegionCountSkewCostFunction(conf));
|
||||||
costFunctions.add(new MoveCostFunction(conf));
|
addCostFunction(new MoveCostFunction(conf));
|
||||||
costFunctions.add(localityCost);
|
addCostFunction(localityCost);
|
||||||
costFunctions.add(rackLocalityCost);
|
addCostFunction(rackLocalityCost);
|
||||||
costFunctions.add(new TableSkewCostFunction(conf));
|
addCostFunction(new TableSkewCostFunction(conf));
|
||||||
costFunctions.add(regionReplicaHostCostFunction);
|
addCostFunction(regionReplicaHostCostFunction);
|
||||||
costFunctions.add(regionReplicaRackCostFunction);
|
addCostFunction(regionReplicaRackCostFunction);
|
||||||
costFunctions.add(regionLoadFunctions[0]);
|
addCostFunction(regionLoadFunctions[0]);
|
||||||
costFunctions.add(regionLoadFunctions[1]);
|
addCostFunction(regionLoadFunctions[1]);
|
||||||
costFunctions.add(regionLoadFunctions[2]);
|
addCostFunction(regionLoadFunctions[2]);
|
||||||
costFunctions.add(regionLoadFunctions[3]);
|
addCostFunction(regionLoadFunctions[3]);
|
||||||
costFunctions.add(regionLoadFunctions[4]);
|
addCostFunction(regionLoadFunctions[4]);
|
||||||
loadCustomCostFunctions(conf);
|
loadCustomCostFunctions(conf);
|
||||||
|
|
||||||
curFunctionCosts= new Double[costFunctions.size()];
|
curFunctionCosts= new Double[costFunctions.size()];
|
||||||
|
@ -514,6 +514,12 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addCostFunction(CostFunction costFunction) {
|
||||||
|
if (costFunction.getMultiplier() > 0) {
|
||||||
|
costFunctions.add(costFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String functionCost() {
|
private String functionCost() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (CostFunction c:costFunctions) {
|
for (CostFunction c:costFunctions) {
|
||||||
|
|
Loading…
Reference in New Issue