HBASE-23116 LoadBalancer should log table name when balancing per table (#689)
This commit adds table name to the logging context when StochasticLoadBalancer is configured "per table". Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
638508e20d
commit
c63b2f4984
|
@ -346,9 +346,11 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
||||||
|
|
||||||
if (total <= 0 || sumMultiplier <= 0
|
if (total <= 0 || sumMultiplier <= 0
|
||||||
|| (sumMultiplier > 0 && (total / sumMultiplier) < minCostNeedBalance)) {
|
|| (sumMultiplier > 0 && (total / sumMultiplier) < minCostNeedBalance)) {
|
||||||
LOG.info("Skipping load balancing because balanced cluster; " + "total cost is " + total
|
final String loadBalanceTarget =
|
||||||
+ ", sum multiplier is " + sumMultiplier + " min cost which need balance is "
|
isByTable ? String.format("table (%s)", tableName) : "cluster";
|
||||||
+ minCostNeedBalance);
|
LOG.info(String.format("Skipping load balancing because the %s is balanced. Total cost: %s, "
|
||||||
|
+ "Sum multiplier: %s, Minimum cost needed for balance: %s", loadBalanceTarget, total,
|
||||||
|
sumMultiplier, minCostNeedBalance));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -160,15 +160,18 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
|
||||||
public void testNeedBalance() {
|
public void testNeedBalance() {
|
||||||
float minCost = conf.getFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.05f);
|
float minCost = conf.getFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.05f);
|
||||||
conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 1.0f);
|
conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 1.0f);
|
||||||
loadBalancer.setConf(conf);
|
try {
|
||||||
for (int[] mockCluster : clusterStateMocks) {
|
loadBalancer.setConf(conf);
|
||||||
Map<ServerName, List<HRegionInfo>> servers = mockClusterServers(mockCluster);
|
for (int[] mockCluster : clusterStateMocks) {
|
||||||
List<RegionPlan> plans = loadBalancer.balanceCluster(servers);
|
Map<ServerName, List<HRegionInfo>> servers = mockClusterServers(mockCluster);
|
||||||
assertNull(plans);
|
List<RegionPlan> plans = loadBalancer.balanceCluster(servers);
|
||||||
|
assertNull(plans);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// reset config
|
||||||
|
conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", minCost);
|
||||||
|
loadBalancer.setConf(conf);
|
||||||
}
|
}
|
||||||
// reset config
|
|
||||||
conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", minCost);
|
|
||||||
loadBalancer.setConf(conf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue