From 97919da711789d7ea55acada4a9746f6f4680bcf Mon Sep 17 00:00:00 2001 From: Kahlil Oppenheimer Date: Tue, 6 Jun 2017 15:53:43 -0400 Subject: [PATCH] HBASE-18164 Fast locality computation in balancer -Added new LocalityCostFunction and LocalityCandidateGenerator that cache localities of every region/rack combination and mappings of every region to its most local server and to its most local rack. -Made LocalityCostFunction incremental so that it only computes locality based on most recent region moves/swaps, rather than recomputing the locality of every region in the cluster at every iteration of the balancer -Changed locality cost function to reflect the ratio of: (Current locality) / (Best locality possible given current cluster) --- .../apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 63ec0b50f9..8ef6e9c1dd 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -1286,8 +1286,9 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { } // We normalize locality to be a score between 0 and 1.0 representing how good it - // is compared to how good it could be - locality /= bestLocality; + // is compared to how good it could be. If bestLocality is 0, assume locality is 100 + // (and the cost is 0) + locality = bestLocality == 0 ? 1 : locality / bestLocality; } @Override -- 2.11.0 (Apple Git-81)