hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1136632 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
Date Thu, 16 Jun 2011 19:55:29 GMT
Author: stack
Date: Thu Jun 16 19:55:29 2011
New Revision: 1136632

URL: http://svn.apache.org/viewvc?rev=1136632&view=rev
Log:
HBASE-3985 Same Region could be picked out twice in LoadBalancer

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1136632&r1=1136631&r2=1136632&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Thu Jun 16 19:55:29 2011
@@ -31,6 +31,8 @@ Release 0.90.4 - Unreleased
    HBASE-3794  Ability to Discard Bad HTable Puts
    HBASE-3916  Fix the default bind address of ThriftServer to be wildcard
                instead of localhost. (Li Pi)
+   HBASE-3985  Same Region could be picked out twice in LoadBalancer
+               (Jieshan Bean)
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java?rev=1136632&r1=1136631&r2=1136632&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java Thu
Jun 16 19:55:29 2011
@@ -164,13 +164,21 @@ public class LoadBalancer {
       return null;
     }
     int numRegions = 0;
+    StringBuilder strBalanceParam = new StringBuilder("Server information: ");
+    
     // Iterate so we can count regions as we build the map
     for(Map.Entry<HServerInfo, List<HRegionInfo>> server:
         clusterState.entrySet()) {
       server.getKey().getLoad().setNumberOfRegions(server.getValue().size());
       numRegions += server.getKey().getLoad().getNumberOfRegions();
       serversByLoad.put(server.getKey(), server.getValue());
-    }
+      
+      strBalanceParam.append(server.getKey().getServerName()).append("=")
+          .append(server.getValue().size()).append(", ");
+    }
+    strBalanceParam.delete(strBalanceParam.length() - 2,
+        strBalanceParam.length());
+    LOG.debug(strBalanceParam.toString());
 
     // Check if we even need to do any load balancing
     float average = (float)numRegions / numServers; // for logging
@@ -189,6 +197,13 @@ public class LoadBalancer {
     int min = numRegions / numServers;
     int max = numRegions % numServers == 0 ? min : min + 1;
 
+    // Using to check banance result.
+    strBalanceParam.delete(0, strBalanceParam.length());
+    strBalanceParam.append("Balance parameter: numRegions=").append(numRegions)
+        .append(", numServers=").append(numServers).append(", max=").append(max)
+        .append(", min=").append(min);
+    LOG.debug(strBalanceParam.toString());
+    
     // Balance the cluster
     // TODO: Look at data block locality or a more complex load to do this
     List<RegionPlan> regionsToMove = new ArrayList<RegionPlan>();
@@ -210,8 +225,8 @@ public class LoadBalancer {
       List<HRegionInfo> regions = randomize(server.getValue());
       int numToOffload = Math.min(regionCount - max, regions.size());
       int numTaken = 0;
-      for (int i = regions.size() - 1; i >= 0; i--) {
-        HRegionInfo hri = regions.get(i);
+      
+      for (HRegionInfo hri: regions) {
         // Don't rebalance meta regions.
         if (hri.isMetaRegion()) continue;
         regionsToMove.add(new RegionPlan(hri, serverInfo, null));



Mime
View raw message