diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 8a7f7dcc6d2..7199ffee382 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -858,7 +858,13 @@ public abstract class BaseLoadBalancer implements LoadBalancer { int leastLoadedServerIndex = -1; int load = Integer.MAX_VALUE; for (ServerName sn : topLocalServers) { - int index = serversToIndex.get(sn); + if (!serversToIndex.containsKey(sn.getHostAndPort())) { + continue; + } + int index = serversToIndex.get(sn.getHostAndPort()); + if (regionsPerServer[index] == null) { + continue; + } int tempLoad = regionsPerServer[index].length; if (tempLoad <= load) { leastLoadedServerIndex = index;