Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,7 @@ void updateMetricsSize(int size) {

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer force balancer to run if there are still cohosted replicas on racks:

  1. there are cases it cannot be satisfied
  2. there are cases we have to accept it as a compromise to have better region count distribution.

}

private String getBalanceReason(double total, double sumMultiplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,8 +162,7 @@ public void testNeedsBalanceForColocatedReplicas() {
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())));
}

Expand Down