hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r703710 - in /hadoop/hbase/branches/0.18: CHANGES.txt src/java/org/apache/hadoop/hbase/RegionHistorian.java src/java/org/apache/hadoop/hbase/master/RegionManager.java
Date Sat, 11 Oct 2008 19:01:55 GMT
Author: jimk
Date: Sat Oct 11 12:01:54 2008
New Revision: 703710

URL: http://svn.apache.org/viewvc?rev=703710&view=rev
Log:
HBASE-918   Region balancing during startup makes cluster unstable

Modified:
    hadoop/hbase/branches/0.18/CHANGES.txt
    hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/RegionHistorian.java
    hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/master/RegionManager.java

Modified: hadoop/hbase/branches/0.18/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.18/CHANGES.txt?rev=703710&r1=703709&r2=703710&view=diff
==============================================================================
--- hadoop/hbase/branches/0.18/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.18/CHANGES.txt Sat Oct 11 12:01:54 2008
@@ -6,6 +6,7 @@
    HBASE-891   HRS.validateValuesLength throws IOE, gets caught in the retries
    HBASE-906   [shell] Truncates output
    HBASE-912   PE is broken when other tables exist
+   HBASE-918   Region balancing during startup makes cluster unstable
 
 Release 0.18.0 - September 21st, 2008
 

Modified: hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/RegionHistorian.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/RegionHistorian.java?rev=703710&r1=703709&r2=703710&view=diff
==============================================================================
--- hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/RegionHistorian.java (original)
+++ hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/RegionHistorian.java Sat Oct
11 12:01:54 2008
@@ -86,7 +86,7 @@
    * Get the RegionHistorian Singleton instance.
    * @return The region historian
    */
-  public static RegionHistorian getInstance() {
+  public synchronized static RegionHistorian getInstance() {
     if (historian == null) {
       historian = new RegionHistorian();
     }

Modified: hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=703710&r1=703709&r2=703710&view=diff
==============================================================================
--- hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/master/RegionManager.java
(original)
+++ hadoop/hbase/branches/0.18/src/java/org/apache/hadoop/hbase/master/RegionManager.java
Sat Oct 11 12:01:54 2008
@@ -178,16 +178,19 @@
       // worked on elsewhere.
       Set<HRegionInfo> regionsToAssign = regionsAwaitingAssignment();
       if (regionsToAssign.size() == 0) {
-        // There are no regions waiting to be assigned. This is an opportunity
-        // for us to check if this server is overloaded. 
-        double avgLoad = master.serverManager.getAverageLoad();
-        if (avgLoad > 2.0 && thisServersLoad.getNumberOfRegions() > avgLoad)
{
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Server " + serverName + " is overloaded. Server load: " + 
-              thisServersLoad.getNumberOfRegions() + " avg: " + avgLoad);
+        // There are no regions waiting to be assigned.
+        if (allRegionsAssigned()) {
+          // We only do load balancing once all regions are assigned.
+          // This prevents churn while the cluster is starting up.
+          double avgLoad = master.serverManager.getAverageLoad();
+          if (avgLoad > 2.0 && thisServersLoad.getNumberOfRegions() > avgLoad)
{
+            if (LOG.isDebugEnabled()) {
+              LOG.debug("Server " + serverName + " is overloaded. Server load: " + 
+                  thisServersLoad.getNumberOfRegions() + " avg: " + avgLoad);
+            }
+            unassignSomeRegions(thisServersLoad, avgLoad, mostLoadedRegions, 
+                returnMsgs);
           }
-          unassignSomeRegions(thisServersLoad, avgLoad, mostLoadedRegions, 
-            returnMsgs);
         }
       } else {
         // if there's only one server, just give it all the regions
@@ -843,6 +846,15 @@
   }
   
   /** 
+   * @return true if the initial meta scan is complete and there are no
+   * unassigned or pending regions
+   */
+  public boolean allRegionsAssigned() {
+    return isInitialMetaScanComplete() && unassignedRegions.size() == 0 &&
+      pendingRegions.size() == 0;
+  }
+  
+  /** 
    * Get the root region location.
    * @return HServerAddress describing root region server.
    */



Mime
View raw message