HBASE-14291 NPE On StochasticLoadBalancer Balance Involving RS With No Regions

This commit is contained in:
tedyu 2015-08-22 14:49:37 -07:00
parent 902cd172f8
commit e95cf8fdb4
1 changed files with 7 additions and 1 deletions

View File

@ -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;