HBASE-19088 move_tables_rsgroup will throw an exception when the table is disabled

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Guangxu Cheng 2017-10-30 16:57:10 +08:00 committed by Andrew Purtell
parent 46408e021d
commit dc127df077
2 changed files with 37 additions and 0 deletions

View File

@ -406,6 +406,10 @@ public class RSGroupAdminServer implements RSGroupAdmin {
// action is required.
if (targetGroup != null) {
for (TableName table: tables) {
if (master.getAssignmentManager().isTableDisabled(table)) {
LOG.debug("Skipping move regions because the table" + table + " is disabled.");
continue;
}
for (RegionInfo region :
master.getAssignmentManager().getRegionStates().getRegionsOfTable(table)) {
LOG.info("Moving region " + region.getShortNameToLog() +

View File

@ -708,6 +708,39 @@ public abstract class TestRSGroupsBase {
assertTrue(newGroupTables.contains(tableNameB));
}
@Test
public void testDisabledTableMove() throws Exception {
final byte[] familyNameBytes = Bytes.toBytes("f");
String newGroupName = getGroupName(name.getMethodName());
final RSGroupInfo newGroup = addGroup(newGroupName, 2);
TEST_UTIL.createMultiRegionTable(tableName, familyNameBytes, 5);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
List<String> regions = getTableRegionMap().get(tableName);
if (regions == null) {
return false;
}
return getTableRegionMap().get(tableName).size() >= 5;
}
});
RSGroupInfo tableGrp = rsGroupAdmin.getRSGroupInfoOfTable(tableName);
assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP));
//test disable table
admin.disableTable(tableName);
//change table's group
LOG.info("Moving table "+ tableName + " to " + newGroup.getName());
rsGroupAdmin.moveTables(Sets.newHashSet(tableName), newGroup.getName());
//verify group change
Assert.assertEquals(newGroup.getName(),
rsGroupAdmin.getRSGroupInfoOfTable(tableName).getName());
}
@Test
public void testMoveServersAndTables() throws Exception {
LOG.info("testMoveServersAndTables");