HBASE-8374 NullPointerException when launching the balancer due to unknown region location (Ted Yu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1469954 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e946c2871f
commit
a2af3a76a2
|
@ -105,10 +105,15 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
|
|||
regionLocations = new int[numRegions][];
|
||||
|
||||
int tableIndex = 0, serverIndex = 0, regionIndex = 0, regionPerServerIndex = 0;
|
||||
// populate serversToIndex first
|
||||
for (Entry<ServerName, List<HRegionInfo>> entry : clusterState.entrySet()) {
|
||||
servers[serverIndex] = entry.getKey();
|
||||
regionsPerServer[serverIndex] = new int[entry.getValue().size()];
|
||||
serversToIndex.put(servers[serverIndex], Integer.valueOf(serverIndex));
|
||||
serverIndex++;
|
||||
}
|
||||
serverIndex = 0;
|
||||
for (Entry<ServerName, List<HRegionInfo>> entry : clusterState.entrySet()) {
|
||||
regionPerServerIndex = 0;
|
||||
for (HRegionInfo region : entry.getValue()) {
|
||||
byte[] tableName = region.getTableName();
|
||||
|
@ -142,7 +147,9 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
|
|||
List<ServerName> loc = regionFinder.getTopBlockLocations(region);
|
||||
regionLocations[regionIndex] = new int[loc.size()];
|
||||
for (int i=0; i < loc.size(); i++) {
|
||||
regionLocations[regionIndex][i] = serversToIndex.get(loc.get(i));
|
||||
regionLocations[regionIndex][i] =
|
||||
loc.get(i) == null ? -1 :
|
||||
(serversToIndex.get(loc.get(i)) == null ? -1 : serversToIndex.get(loc.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
|||
|
||||
int index = -1;
|
||||
for (int j = 0; j < regionLocations.length; j++) {
|
||||
if (regionLocations[j] == serverIndex) {
|
||||
if (regionLocations[j] >= 0 && regionLocations[j] == serverIndex) {
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue