HBASE-4194 RegionSplitter: Split on under-loaded region servers first

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1157374 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-08-13 12:48:20 +00:00
parent 5c8f6d6c9e
commit 6969402718
2 changed files with 28 additions and 4 deletions

View File

@ -200,6 +200,7 @@ Release 0.91.0 - Unreleased
HBASE-4184 CatalogJanitor doesn't work properly when "fs.default.name" isn't
set in config file (Ming Ma)
HBASE-4186 No region is added to regionsInTransitionInRS
HBASE-4194 RegionSplitter: Split on under-loaded region servers first
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -21,7 +21,11 @@ package org.apache.hadoop.hbase.util;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@ -396,10 +400,29 @@ public class RegionSplitter {
while (!daughterRegions.isEmpty()) {
LOG.debug(daughterRegions.size() + " RS have regions to splt.");
// round-robin through the RS list
for (HServerAddress rsLoc = daughterRegions.firstKey();
rsLoc != null;
rsLoc = daughterRegions.higherKey(rsLoc)) {
// Get RegionServer : region count mapping
final TreeMap<HServerAddress, Integer> rsSizes = Maps.newTreeMap();
Map<HRegionInfo, HServerAddress> regionsInfo = table.getRegionsInfo();
for (HServerAddress rs : regionsInfo.values()) {
if (rsSizes.containsKey(rs)) {
rsSizes.put(rs, rsSizes.get(rs) + 1);
} else {
rsSizes.put(rs, 1);
}
}
// sort the RS by the number of regions they have
List<HServerAddress> serversLeft = Lists.newArrayList(daughterRegions
.keySet());
Collections.sort(serversLeft, new Comparator<HServerAddress>() {
public int compare(HServerAddress o1, HServerAddress o2) {
return rsSizes.get(o1).compareTo(rsSizes.get(o2));
}
});
// round-robin through the RS list. Choose the lightest-loaded servers
// first to keep the master from load-balancing regions as we split.
for (HServerAddress rsLoc : serversLeft) {
Pair<byte[], byte[]> dr = null;
// find a region in the RS list that hasn't been moved