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 84baa7f3ce3..962b241663f 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 @@ -860,7 +860,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;