HBASE-21297 ModifyTableProcedure can throw TNDE instead of IOE in case of REGION_REPLICATION change
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
52bc6db050
commit
5d32e80f9e
|
@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.HBaseIOException;
|
|||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.TableNotDisabledException;
|
||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||
|
@ -249,7 +250,8 @@ public class ModifyTableProcedure
|
|||
.isTableState(getTableName(), TableState.State.ENABLED)) {
|
||||
if (modifiedTableDescriptor.getRegionReplication() != unmodifiedTableDescriptor
|
||||
.getRegionReplication()) {
|
||||
throw new IOException("REGION_REPLICATION change is not supported for enabled tables");
|
||||
throw new TableNotDisabledException(
|
||||
"REGION_REPLICATION change is not supported for enabled tables");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -523,6 +523,26 @@ public class TestAdmin1 {
|
|||
assertFalse(this.admin.tableExists(tableName));
|
||||
}
|
||||
|
||||
@Test(expected = TableNotDisabledException.class)
|
||||
public void testModifyRegionReplicasEnabledTable() throws Exception {
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||
|
||||
// Modify region replication count
|
||||
TableDescriptor htd = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
|
||||
.setRegionReplication(3).build();
|
||||
try {
|
||||
// try to modify the region replication count without disabling the table
|
||||
admin.modifyTable(htd);
|
||||
fail("Expected an exception");
|
||||
} finally {
|
||||
// Delete the table
|
||||
admin.disableTable(tableName);
|
||||
admin.deleteTable(tableName);
|
||||
assertFalse(admin.tableExists(tableName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify schema modification takes.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue