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