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:
parent
264cf0d473
commit
dc1310f487
|
@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.master.RegionState;
|
|||
import org.apache.hadoop.hbase.master.ServerManager;
|
||||
import org.apache.hadoop.hbase.master.TableLockManager.TableLock;
|
||||
import org.apache.hadoop.hbase.net.Address;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
|
||||
|
||||
/**
|
||||
* Service to support Region Server Grouping (HBase-6721)
|
||||
|
@ -276,6 +277,12 @@ public class RSGroupAdminServer implements RSGroupAdmin {
|
|||
}
|
||||
}
|
||||
for(TableName table: tables) {
|
||||
if (master.getAssignmentManager().getTableStateManager().isTableState(table,
|
||||
ZooKeeperProtos.Table.State.DISABLED,
|
||||
ZooKeeperProtos.Table.State.DISABLING)) {
|
||||
LOG.debug("Skipping move regions because the table" + table + " is disabled.");
|
||||
continue;
|
||||
}
|
||||
TableLock lock = master.getTableLockManager().writeLock(table, "Group: table move");
|
||||
try {
|
||||
lock.acquire();
|
||||
|
|
|
@ -812,4 +812,38 @@ public abstract class TestRSGroupsBase {
|
|||
Set<TableName> newGroupTables = rsGroupAdmin.getRSGroupInfo(newGroup.getName()).getTables();
|
||||
assertTrue(newGroupTables.contains(tableName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabledTableMove() throws Exception {
|
||||
final TableName tableName = TableName.valueOf(tablePrefix + "_testDisabledTableMove");
|
||||
final byte[] familyNameBytes = Bytes.toBytes("f");
|
||||
String newGroupName = getGroupName("testDisabledTableMove");
|
||||
final RSGroupInfo newGroup = addGroup(rsGroupAdmin, 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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue