hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1157374 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
Date Sat, 13 Aug 2011 12:48:20 GMT
Author: tedyu
Date: Sat Aug 13 12:48:20 2011
New Revision: 1157374

URL: http://svn.apache.org/viewvc?rev=1157374&view=rev
Log:
HBASE-4194  RegionSplitter: Split on under-loaded region servers first

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1157374&r1=1157373&r2=1157374&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Aug 13 12:48:20 2011
@@ -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)  

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java?rev=1157374&r1=1157373&r2=1157374&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java Sat Aug 13
12:48:20 2011
@@ -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



Mime
View raw message