HBASE-26327 Replicas cohosted on a rack shouldn't keep triggering Bal… (#3729)
Signed-off-by: Huaxiang Sun <huaxiangsun@apache.org>
This commit is contained in:
parent
ffb20ca20c
commit
7af5277859
|
@ -311,14 +311,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
|||
|
||||
private boolean areSomeRegionReplicasColocated(BalancerClusterState c) {
|
||||
regionReplicaHostCostFunction.prepare(c);
|
||||
if (Math.abs(regionReplicaHostCostFunction.cost()) > CostFunction.COST_EPSILON) {
|
||||
return true;
|
||||
}
|
||||
regionReplicaRackCostFunction.prepare(c);
|
||||
if (Math.abs(regionReplicaRackCostFunction.cost()) > CostFunction.COST_EPSILON) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (Math.abs(regionReplicaHostCostFunction.cost()) > CostFunction.COST_EPSILON);
|
||||
}
|
||||
|
||||
private String getBalanceReason(double total, double sumMultiplier) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.hbase.master.balancer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -161,8 +162,7 @@ public class TestStochasticLoadBalancerRegionReplica extends StochasticBalancerT
|
|||
map.put(s2, regionsOnS2);
|
||||
// add another server so that the cluster has some host on another rack
|
||||
map.put(ServerName.valueOf("host2", 1000, 11111), randomRegions(1));
|
||||
assertTrue(
|
||||
loadBalancer.needsBalance(HConstants.ENSEMBLE_TABLE_NAME,
|
||||
assertFalse(loadBalancer.needsBalance(HConstants.ENSEMBLE_TABLE_NAME,
|
||||
new BalancerClusterState(map, null, null, new ForTestRackManagerOne())));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue