From 0e39b8b9f78b0a660bf041192eb7b0cecc8da444 Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 29 Dec 2014 07:44:46 -0800 Subject: [PATCH] HBASE-12762 Region with no hfiles will have the highest locality cost in LocalityCostFunction (cuijianwei) --- .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 5119614d0d8..e58f855b1a4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -1026,7 +1026,9 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { } if (index < 0) { - cost += 1; + if (regionLocations.length > 0) { + cost += 1; + } } else { cost += (double) index / (double) regionLocations.length; }