From fcc84c258f63bf1f0712f0a62a2ba93d42dbf477 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 25 Aug 2009 22:44:15 +0000 Subject: [PATCH] HBASE-1737 Regions unbalanced when adding new node (recommit) git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@807846 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../hadoop/hbase/master/RegionManager.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 62a5d694a5e..cc1297d739b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ Release 0.21.0 - Unreleased BUG FIXES HBASE-1791 Timeout in IndexRecordWriter (Bradford Stephens via Andrew Purtell) + HBASE-1737 Regions unbalanced when adding new node (recommit) IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/java/org/apache/hadoop/hbase/master/RegionManager.java b/src/java/org/apache/hadoop/hbase/master/RegionManager.java index 020136565d6..aee7c88796b 100644 --- a/src/java/org/apache/hadoop/hbase/master/RegionManager.java +++ b/src/java/org/apache/hadoop/hbase/master/RegionManager.java @@ -1349,19 +1349,24 @@ class RegionManager implements HConstants { double avg = master.serverManager.getAverageLoad(); // nothing to balance if server load not more then average load - if (servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) return; + if(servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) { + return; + } - // check if server is overloaded + // check if current server is overloaded int numRegionsToClose = balanceFromOverloaded(servLoad, avg); // check if we can unload server by low loaded servers - if (numRegionsToClose <= 0) - balanceToLowloaded(info.getServerName(), servLoad, avg); + if(numRegionsToClose <= 0) { + numRegionsToClose = balanceToLowloaded(info.getServerName(), servLoad, + avg); + } - if (maxRegToClose > 0) + if(maxRegToClose > 0) { numRegionsToClose = Math.min(numRegionsToClose, maxRegToClose); - - if (numRegionsToClose > 0){ + } + + if(numRegionsToClose > 0) { unassignSomeRegions(info, numRegionsToClose, mostLoadedRegions, returnMsgs); } @@ -1416,7 +1421,8 @@ class RegionManager implements HConstants { if (LOG.isDebugEnabled()) { LOG.debug("Server " + srvName + " will be unloaded for " + "balance. Server load: " + numSrvRegs + " avg: " + - avgLoad + ", regions can be moved: " + numMoveToLowLoaded); + avgLoad + ", regions can be moved: " + numMoveToLowLoaded + + ". Regions to close: " + numRegionsToClose); } return numRegionsToClose; }