From 6b96b0ce853b83cf445018292217f736fbff906d Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Thu, 19 Jan 2017 14:21:24 -0800 Subject: [PATCH] HBASE-17658 Fix bookkeeping error with max regions for a table Signed-off-by: tedyu --- .../apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java | 2 +- .../hadoop/hbase/master/balancer/TestBaseLoadBalancer.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 498d03dc139..27c4a89e225 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -661,7 +661,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer { //check whether this caused maxRegionsPerTable in the new Server to be updated if (numRegionsPerServerPerTable[newServer][tableIndex] > numMaxRegionsPerTable[tableIndex]) { - numRegionsPerServerPerTable[newServer][tableIndex] = numMaxRegionsPerTable[tableIndex]; + numMaxRegionsPerTable[tableIndex] = numRegionsPerServerPerTable[newServer][tableIndex]; } else if (oldServer >= 0 && (numRegionsPerServerPerTable[oldServer][tableIndex] + 1) == numMaxRegionsPerTable[tableIndex]) { //recompute maxRegionsPerTable since the previous value was coming from the old server diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java index e3523b1779e..2823d649ce6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java @@ -326,6 +326,8 @@ public class TestBaseLoadBalancer extends BalancerTestBase { // now move region1 from servers[0] to servers[2] cluster.doAction(new MoveRegionAction(0, 0, 2)); + // check that the numMaxRegionsPerTable for "table" has increased to 2 + assertEquals(2, cluster.numMaxRegionsPerTable[0]); // now repeat check whether moving region1 from servers[1] to servers[2] // would lower availability assertTrue(cluster.wouldLowerAvailability(hri1, servers[2]));