HBASE-1868 Spew about rebalancing but none done....
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@820173 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c2db3972ec
commit
9719bcba95
|
@ -196,8 +196,8 @@ class RegionManager implements HConstants {
|
||||||
|
|
||||||
// figure out what regions need to be assigned and aren't currently being
|
// figure out what regions need to be assigned and aren't currently being
|
||||||
// worked on elsewhere.
|
// worked on elsewhere.
|
||||||
Set<RegionState> regionsToAssign = regionsAwaitingAssignment(info.getServerAddress(),
|
Set<RegionState> regionsToAssign =
|
||||||
isSingleServer);
|
regionsAwaitingAssignment(info.getServerAddress(), isSingleServer);
|
||||||
if (regionsToAssign.size() == 0) {
|
if (regionsToAssign.size() == 0) {
|
||||||
// There are no regions waiting to be assigned.
|
// There are no regions waiting to be assigned.
|
||||||
if (!inSafeMode()) {
|
if (!inSafeMode()) {
|
||||||
|
@ -224,69 +224,88 @@ class RegionManager implements HConstants {
|
||||||
* Note that no synchronization is needed while we iterate over
|
* Note that no synchronization is needed while we iterate over
|
||||||
* regionsInTransition because this method is only called by assignRegions
|
* regionsInTransition because this method is only called by assignRegions
|
||||||
* whose caller owns the monitor for RegionManager
|
* whose caller owns the monitor for RegionManager
|
||||||
*/
|
*
|
||||||
|
* TODO: This code is unintelligible. REWRITE. Add TESTS! St.Ack 09/30/2009
|
||||||
|
* @param thisServersLoad
|
||||||
|
* @param regionsToAssign
|
||||||
|
* @param info
|
||||||
|
* @param returnMsgs
|
||||||
|
*/
|
||||||
private void assignRegionsToMultipleServers(final HServerLoad thisServersLoad,
|
private void assignRegionsToMultipleServers(final HServerLoad thisServersLoad,
|
||||||
final Set<RegionState> regionsToAssign, final HServerInfo info,
|
final Set<RegionState> regionsToAssign, final HServerInfo info,
|
||||||
final ArrayList<HMsg> returnMsgs) {
|
final ArrayList<HMsg> returnMsgs) {
|
||||||
|
|
||||||
boolean isMetaAssign = false;
|
boolean isMetaAssign = false;
|
||||||
for (RegionState s : regionsToAssign) {
|
for (RegionState s : regionsToAssign) {
|
||||||
if (s.getRegionInfo().isMetaRegion())
|
if (s.getRegionInfo().isMetaRegion())
|
||||||
isMetaAssign = true;
|
isMetaAssign = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nRegionsToAssign = regionsToAssign.size();
|
int nRegionsToAssign = regionsToAssign.size();
|
||||||
|
// Now many regions to assign this server.
|
||||||
int nregions = regionsPerServer(nRegionsToAssign, thisServersLoad);
|
int nregions = regionsPerServer(nRegionsToAssign, thisServersLoad);
|
||||||
LOG.debug("Assigning for " + info + ": total nregions to assign=" +
|
LOG.debug("Assigning for " + info + ": total nregions to assign=" +
|
||||||
nRegionsToAssign + ", nregions to reach balance=" + nregions +
|
nRegionsToAssign + ", nregions to reach balance=" + nregions +
|
||||||
", isMetaAssign=" + isMetaAssign);
|
", isMetaAssign=" + isMetaAssign);
|
||||||
nRegionsToAssign -= nregions;
|
if (nRegionsToAssign <= nregions) {
|
||||||
if (nRegionsToAssign > 0 || isMetaAssign) {
|
// I do not know whats supposed to happen in this case. Assign one.
|
||||||
// We still have more regions to assign. See how many we can assign
|
LOG.debug("Assigning one region only (playing it safe..)");
|
||||||
// before this server becomes more heavily loaded than the next
|
assignRegions(regionsToAssign, 1, info, returnMsgs);
|
||||||
// most heavily loaded server.
|
} else {
|
||||||
HServerLoad heavierLoad = new HServerLoad();
|
nRegionsToAssign -= nregions;
|
||||||
int nservers = computeNextHeaviestLoad(thisServersLoad, heavierLoad);
|
if (nRegionsToAssign > 0 || isMetaAssign) {
|
||||||
|
// We still have more regions to assign. See how many we can assign
|
||||||
nregions = 0;
|
// before this server becomes more heavily loaded than the next
|
||||||
|
// most heavily loaded server.
|
||||||
// Advance past any less-loaded servers
|
HServerLoad heavierLoad = new HServerLoad();
|
||||||
for (HServerLoad load = new HServerLoad(thisServersLoad);
|
int nservers = computeNextHeaviestLoad(thisServersLoad, heavierLoad);
|
||||||
|
nregions = 0;
|
||||||
|
// Advance past any less-loaded servers
|
||||||
|
for (HServerLoad load = new HServerLoad(thisServersLoad);
|
||||||
load.compareTo(heavierLoad) <= 0 && nregions < nRegionsToAssign;
|
load.compareTo(heavierLoad) <= 0 && nregions < nRegionsToAssign;
|
||||||
load.setNumberOfRegions(load.getNumberOfRegions() + 1), nregions++) {
|
load.setNumberOfRegions(load.getNumberOfRegions() + 1), nregions++) {
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
|
LOG.debug("Doing for " + info + " nregions: " + nregions +
|
||||||
LOG.debug("Doing for " + info + " nregions: " + nregions +
|
" and nRegionsToAssign: " + nRegionsToAssign);
|
||||||
" and nRegionsToAssign: " + nRegionsToAssign);
|
if (nregions < nRegionsToAssign) {
|
||||||
if (nregions < nRegionsToAssign) {
|
// There are some more heavily loaded servers
|
||||||
// There are some more heavily loaded servers
|
// but we can't assign all the regions to this server.
|
||||||
// but we can't assign all the regions to this server.
|
if (nservers > 0) {
|
||||||
if (nservers > 0) {
|
// There are other servers that can share the load.
|
||||||
// There are other servers that can share the load.
|
// Split regions that need assignment across the servers.
|
||||||
// Split regions that need assignment across the servers.
|
nregions = (int) Math.ceil((1.0 * nRegionsToAssign)/(1.0 * nservers));
|
||||||
nregions = (int) Math.ceil((1.0 * nRegionsToAssign)
|
} else {
|
||||||
/ (1.0 * nservers));
|
// No other servers with same load.
|
||||||
|
// Split regions over all available servers
|
||||||
|
nregions = (int) Math.ceil((1.0 * nRegionsToAssign)/
|
||||||
|
(1.0 * master.serverManager.numServers()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No other servers with same load.
|
// Assign all regions to this server
|
||||||
// Split regions over all available servers
|
nregions = nRegionsToAssign;
|
||||||
nregions = (int) Math.ceil((1.0 * nRegionsToAssign)
|
|
||||||
/ (1.0 * master.serverManager.numServers()));
|
|
||||||
}
|
}
|
||||||
} else {
|
assignRegions(regionsToAssign, nregions, info, returnMsgs);
|
||||||
// Assign all regions to this server
|
|
||||||
nregions = nRegionsToAssign;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nregions > this.maxAssignInOneGo) {
|
/*
|
||||||
nregions = this.maxAssignInOneGo;
|
* Assign <code>nregions</code> regions.
|
||||||
}
|
* @param regionsToAssign
|
||||||
|
* @param nregions
|
||||||
for (RegionState s: regionsToAssign) {
|
* @param info
|
||||||
doRegionAssignment(s, info, returnMsgs);
|
* @param returnMsgs
|
||||||
if (--nregions <= 0) {
|
*/
|
||||||
break;
|
private void assignRegions(final Set<RegionState> regionsToAssign,
|
||||||
}
|
final int nregions, final HServerInfo info,
|
||||||
|
final ArrayList<HMsg> returnMsgs) {
|
||||||
|
int count = nregions;
|
||||||
|
if (count > this.maxAssignInOneGo) {
|
||||||
|
count = this.maxAssignInOneGo;
|
||||||
|
}
|
||||||
|
for (RegionState s: regionsToAssign) {
|
||||||
|
doRegionAssignment(s, info, returnMsgs);
|
||||||
|
if (--count <= 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +351,6 @@ class RegionManager implements HConstants {
|
||||||
*/
|
*/
|
||||||
private int regionsPerServer(final int numUnassignedRegions,
|
private int regionsPerServer(final int numUnassignedRegions,
|
||||||
final HServerLoad thisServersLoad) {
|
final HServerLoad thisServersLoad) {
|
||||||
|
|
||||||
SortedMap<HServerLoad, Set<String>> lightServers =
|
SortedMap<HServerLoad, Set<String>> lightServers =
|
||||||
new TreeMap<HServerLoad, Set<String>>();
|
new TreeMap<HServerLoad, Set<String>>();
|
||||||
|
|
||||||
|
@ -346,14 +364,13 @@ class RegionManager implements HConstants {
|
||||||
// until they reach load equal with ours. Then, see how many regions are left
|
// until they reach load equal with ours. Then, see how many regions are left
|
||||||
// unassigned. That is how many regions we should assign to this server.
|
// unassigned. That is how many regions we should assign to this server.
|
||||||
int nRegions = 0;
|
int nRegions = 0;
|
||||||
for (Map.Entry<HServerLoad, Set<String>> e : lightServers.entrySet()) {
|
for (Map.Entry<HServerLoad, Set<String>> e: lightServers.entrySet()) {
|
||||||
HServerLoad lightLoad = new HServerLoad(e.getKey());
|
HServerLoad lightLoad = new HServerLoad(e.getKey());
|
||||||
do {
|
do {
|
||||||
lightLoad.setNumberOfRegions(lightLoad.getNumberOfRegions() + 1);
|
lightLoad.setNumberOfRegions(lightLoad.getNumberOfRegions() + 1);
|
||||||
nRegions += 1;
|
nRegions += 1;
|
||||||
} while (lightLoad.compareTo(thisServersLoad) <= 0
|
} while (lightLoad.compareTo(thisServersLoad) <= 0
|
||||||
&& nRegions < numUnassignedRegions);
|
&& nRegions < numUnassignedRegions);
|
||||||
|
|
||||||
nRegions *= e.getValue().size();
|
nRegions *= e.getValue().size();
|
||||||
if (nRegions >= numUnassignedRegions) {
|
if (nRegions >= numUnassignedRegions) {
|
||||||
break;
|
break;
|
||||||
|
@ -361,7 +378,7 @@ class RegionManager implements HConstants {
|
||||||
}
|
}
|
||||||
return nRegions;
|
return nRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the set of regions that should be assignable in this pass.
|
* Get the set of regions that should be assignable in this pass.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue