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:
Bharath Vissapragada 2019-10-04 15:39:50 -07:00 committed by Andrew Purtell
parent 638508e20d
commit c63b2f4984
2 changed files with 16 additions and 11 deletions

View File

@ -346,9 +346,11 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
if (total <= 0 || sumMultiplier <= 0
|| (sumMultiplier > 0 && (total / sumMultiplier) < minCostNeedBalance)) {
LOG.info("Skipping load balancing because balanced cluster; " + "total cost is " + total
+ ", sum multiplier is " + sumMultiplier + " min cost which need balance is "
+ minCostNeedBalance);
final String loadBalanceTarget =
isByTable ? String.format("table (%s)", tableName) : "cluster";
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 true;

View File

@ -160,15 +160,18 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
public void testNeedBalance() {
float minCost = conf.getFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.05f);
conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 1.0f);
loadBalancer.setConf(conf);
for (int[] mockCluster : clusterStateMocks) {
Map<ServerName, List<HRegionInfo>> servers = mockClusterServers(mockCluster);
List<RegionPlan> plans = loadBalancer.balanceCluster(servers);
assertNull(plans);
try {
loadBalancer.setConf(conf);
for (int[] mockCluster : clusterStateMocks) {
Map<ServerName, List<HRegionInfo>> servers = mockClusterServers(mockCluster);
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);
}
/**