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

This commit is contained in:
tedyu 2015-08-22 14:50:57 -07:00
parent 234a4632a4
commit 0b081303b9
1 changed files with 7 additions and 1 deletions

View File

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