HBASE-18051 balance_rsgroup still runs when the Load Balancer is not enabled

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Guangxu Cheng 2017-05-16 12:58:20 +08:00 committed by tedyu
parent 67d1358311
commit a8775b11d2
3 changed files with 16 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.master.AssignmentManager;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.LoadBalancer;
import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.master.RegionPlan;
@ -492,6 +493,8 @@ public class RSGroupAdminServer implements RSGroupAdmin {
boolean balancerRan;
synchronized (balancer) {
// If balance not true, don't run balancer.
if (!((HMaster) master).isBalancerOn()) return false;
if (master.getMasterCoprocessorHost() != null) {
master.getMasterCoprocessorHost().preBalanceRSGroup(groupName);
}

View File

@ -260,7 +260,9 @@ public class TestRSGroups extends TestRSGroupsBase {
rsGroupAdminEndpoint.getGroupInfoManager()
.moveTables(Sets.newHashSet(tableName), RSGroupInfo.getName());
admin.setBalancerRunning(true,true);
assertTrue(rsGroupAdmin.balanceRSGroup(RSGroupInfo.getName()));
admin.setBalancerRunning(false,true);
TEST_UTIL.waitFor(60000, new Predicate<Exception>() {
@Override

View File

@ -210,7 +210,9 @@ public abstract class TestRSGroupsBase {
}
try {
admin.setBalancerRunning(true,true);
rsGroupAdmin.balanceRSGroup("bogus");
admin.setBalancerRunning(false,true);
fail("Expected move with bogus group to fail");
} catch(ConstraintException ex) {
//expected
@ -433,9 +435,17 @@ public abstract class TestRSGroupsBase {
});
//balance the other group and make sure it doesn't affect the new group
admin.setBalancerRunning(true,true);
rsGroupAdmin.balanceRSGroup(RSGroupInfo.DEFAULT_GROUP);
assertEquals(6, getTableServerRegionMap().get(tableName).get(first).size());
//disable balance, balancer will not be run and return false
admin.setBalancerRunning(false,true);
assertFalse(rsGroupAdmin.balanceRSGroup(newGroupName));
assertEquals(6, getTableServerRegionMap().get(tableName).get(first).size());
//enable balance
admin.setBalancerRunning(true,true);
rsGroupAdmin.balanceRSGroup(newGroupName);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
@Override
@ -448,6 +458,7 @@ public abstract class TestRSGroupsBase {
return true;
}
});
admin.setBalancerRunning(false,true);
}
@Test