rmdmattingly commented on code in PR #6593:
URL: https://github.com/apache/hbase/pull/6593#discussion_r1911393421
##########
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java:
##########
@@ -332,8 +344,41 @@ void updateMetricsSize(int size) {
}
private boolean areSomeRegionReplicasColocated(BalancerClusterState c) {
- regionReplicaHostCostFunction.prepare(c);
- return (Math.abs(regionReplicaHostCostFunction.cost()) >
CostFunction.COST_EPSILON);
+ if (!c.hasRegionReplicas ||
balancerConditionals.isReplicaDistributionEnabled()) {
+ // This check is unnecessary without replicas, or with conditional
replica distribution
+ // The balancer will auto-run if conditional replica distribution
candidates are available
+ return false;
+ }
+ return areSomeRegionReplicasColocatedOnHost(c) ||
areSomeRegionReplicasColocatedOnRack(c);
+ }
+
+ private boolean areSomeRegionReplicasColocatedOnHost(BalancerClusterState c)
{
+ if (c.numHosts >= c.maxReplicas) {
+ regionReplicaHostCostFunction.prepare(c);
+ double hostCost = Math.abs(regionReplicaHostCostFunction.cost());
+ boolean colocatedAtHost = hostCost > CostFunction.COST_EPSILON;
+ if (colocatedAtHost) {
+ return true;
+ }
+ LOG.trace("No host colocation detected with host cost={}", hostCost);
+ }
+ return false;
+ }
+
+ private boolean areSomeRegionReplicasColocatedOnRack(BalancerClusterState c)
{
Review Comment:
In [HBASE-26327](https://github.com/apache/hbase/pull/3729) we removed
consideration for distribution of replicas across racks. This was, in my
opinion, a mistake — if we want to be flexible for environments that have too
few racks, then we should just do so by skipping this check when the rack count
is < the max replica count
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]