From 21a5df7b4fdd16b31c7e3689253e9f784ace9d17 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 7 Dec 2010 05:26:39 +0000 Subject: [PATCH] HBASE-3278 AssertionError in LoadBalancer git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1042912 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java | 3 ++- .../java/org/apache/hadoop/hbase/master/TestLoadBalancer.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3f9e55bf1da..74a91afc870 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -746,6 +746,7 @@ Release 0.90.0 - Unreleased HBASE-3309 " Not running balancer because dead regionserver processing" is a lie HBASE-3314 [shell] 'move' is broken HBASE-3315 Add debug output for when balancer makes bad balance + HBASE-3278 AssertionError in LoadBalancer IMPROVEMENTS diff --git a/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java b/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java index 9fdd7240635..15f65c60b65 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java +++ b/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java @@ -259,12 +259,13 @@ public class LoadBalancer { for(Map.Entry> server : serversByLoad.entrySet()) { int regionCount = server.getKey().getLoad().getNumberOfRegions(); + if (regionCount >= min) break; BalanceInfo balanceInfo = serverBalanceInfo.get(server.getKey()); if(balanceInfo != null) { regionCount += balanceInfo.getNumRegionsAdded(); } if(regionCount >= min) { - break; + continue; } int numToTake = min - regionCount; int numTaken = 0; diff --git a/src/test/java/org/apache/hadoop/hbase/master/TestLoadBalancer.java b/src/test/java/org/apache/hadoop/hbase/master/TestLoadBalancer.java index c9751466d36..ca2a4bcbe92 100644 --- a/src/test/java/org/apache/hadoop/hbase/master/TestLoadBalancer.java +++ b/src/test/java/org/apache/hadoop/hbase/master/TestLoadBalancer.java @@ -110,7 +110,8 @@ public class TestLoadBalancer { new int [] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 123 }, new int [] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 155 }, new int [] { 0, 0, 144, 1, 1, 1, 1, 1123, 133, 138, 12, 1444 }, - new int [] { 0, 0, 144, 1, 0, 4, 1, 1123, 133, 138, 12, 1444 } + new int [] { 0, 0, 144, 1, 0, 4, 1, 1123, 133, 138, 12, 1444 }, + new int [] { 1538, 1392, 1561, 1557, 1535, 1553, 1385, 1542, 1619 } }; int [][] regionsAndServersMocks = new int [][] {