Skip to content

Commit

Permalink
HBASE-21297 ModifyTableProcedure can throw TNDE instead of IOE in cas…
Browse files Browse the repository at this point in the history
…e of REGION_REPLICATION change

Signed-off-by: Guanghao Zhang <[email protected]>
  • Loading branch information
NihalJain authored and infraio committed Jan 10, 2019
1 parent 52bc6db commit 5d32e80
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -249,7 +250,8 @@ private void prepareModify(final MasterProcedureEnv env) throws IOException {
.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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,26 @@ public void testReadOnlyTableModify() throws IOException, InterruptedException {
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.
*/
Expand Down

0 comments on commit 5d32e80

Please sign in to comment.