HBASE-10704 BaseLoadBalancer#roundRobinAssignment() may add same region to assignment plan multiple times

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-10070@1576156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2014-03-11 00:41:31 +00:00 committed by Enis Soztutar
parent c2f6f479ad
commit 55a7c87294
1 changed files with 5 additions and 2 deletions

View File

@ -1159,6 +1159,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
// assign the remaining by going through the list and try to assign to servers one-by-one
int serverIdx = RANDOM.nextInt(numServers);
for (HRegionInfo region : unassignedRegions) {
boolean assigned = false;
for (int j = 0; j < numServers; j++) { // try all servers one by one
ServerName serverName = servers.get((j + serverIdx) % numServers);
if (serverName.equals(masterServerName)) {
@ -1173,11 +1174,13 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
serverRegions.add(region);
cluster.doAssignRegion(region, serverName);
serverIdx = (j + serverIdx + 1) % numServers; //remain from next server
assigned = true;
break;
} else {
lastFewRegions.add(region);
}
}
if (!assigned) {
lastFewRegions.add(region);
}
}
// just sprinkle the rest of the regions on random regionservers. The balanceCluster will
// make it optimal later. we can end up with this if numReplicas > numServers.