HBASE-14332 Show the table state when we encounter exception while disabling / enabling table (Nick Han)
This commit is contained in:
parent
4f410e6bd5
commit
f792ede466
|
@ -77,9 +77,10 @@ public class TableStateManager {
|
|||
* @param tableName table to change state for
|
||||
* @param newState new state
|
||||
* @param states states to check against
|
||||
* @return null if succeed or table state if failed
|
||||
* @throws IOException
|
||||
*/
|
||||
public boolean setTableStateIfInStates(TableName tableName,
|
||||
public TableState.State setTableStateIfInStates(TableName tableName,
|
||||
TableState.State newState,
|
||||
TableState.State... states)
|
||||
throws IOException {
|
||||
|
@ -91,9 +92,9 @@ public class TableStateManager {
|
|||
}
|
||||
if (currentState.inStates(states)) {
|
||||
udpateMetaState(tableName, newState);
|
||||
return true;
|
||||
return null;
|
||||
} else {
|
||||
return false;
|
||||
return currentState.getState();
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
|
|
|
@ -90,11 +90,13 @@ public class DisableTableHandler extends EventHandler {
|
|||
// DISABLED or ENABLED.
|
||||
//TODO: reevaluate this since we have table locks now
|
||||
if (!skipTableStateCheck) {
|
||||
if (!this.assignmentManager.getTableStateManager().setTableStateIfInStates(
|
||||
this.tableName, TableState.State.DISABLING,
|
||||
TableState.State.ENABLED)) {
|
||||
LOG.info("Table " + tableName + " isn't enabled; skipping disable");
|
||||
throw new TableNotEnabledException(this.tableName);
|
||||
TableState.State state = this.assignmentManager.
|
||||
getTableStateManager().setTableStateIfInStates(
|
||||
this.tableName, TableState.State.DISABLING,
|
||||
TableState.State.ENABLED);
|
||||
if (state!=null) {
|
||||
LOG.info("Table " + tableName + " isn't enabled;is "+state.name()+"; skipping disable");
|
||||
throw new TableNotEnabledException(this.tableName+" state is "+state.name());
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
|
|
|
@ -100,11 +100,13 @@ public class EnableTableHandler extends EventHandler {
|
|||
// After that, no other requests can be accepted until the table reaches
|
||||
// DISABLED or ENABLED.
|
||||
if (!skipTableStateCheck) {
|
||||
if (!this.assignmentManager.getTableStateManager().setTableStateIfInStates(
|
||||
this.tableName, TableState.State.ENABLING,
|
||||
TableState.State.DISABLED)) {
|
||||
LOG.info("Table " + tableName + " isn't disabled; skipping enable");
|
||||
throw new TableNotDisabledException(this.tableName);
|
||||
TableState.State state = this.assignmentManager
|
||||
.getTableStateManager().setTableStateIfInStates(
|
||||
this.tableName, TableState.State.ENABLING,
|
||||
TableState.State.DISABLED);
|
||||
if (state!=null) {
|
||||
LOG.info("Table " + tableName + " isn't disabled;is "+state.name()+"; skipping enable");
|
||||
throw new TableNotDisabledException(this.tableName+" state is "+state.name());
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
|
|
|
@ -294,9 +294,11 @@ public class DisableTableProcedure
|
|||
// set the state later on). A quick state check should be enough for us to move forward.
|
||||
TableStateManager tsm =
|
||||
env.getMasterServices().getAssignmentManager().getTableStateManager();
|
||||
if (!tsm.getTableState(tableName).equals(TableState.State.ENABLED)) {
|
||||
LOG.info("Table " + tableName + " isn't enabled; skipping disable");
|
||||
setFailure("master-disable-table", new TableNotEnabledException(tableName));
|
||||
TableState.State state = tsm.getTableState(tableName);
|
||||
if(!state.equals(TableState.State.ENABLED)){
|
||||
LOG.info("Table " + tableName + " isn't enabled;is "+state.name()+"; skipping disable");
|
||||
setFailure("master-disable-table", new TableNotEnabledException(
|
||||
tableName+" state is "+state.name()));
|
||||
canTableBeDisabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -314,9 +314,11 @@ public class EnableTableProcedure
|
|||
// was implemented. With table lock, there is no need to set the state here (it will
|
||||
// set the state later on). A quick state check should be enough for us to move forward.
|
||||
TableStateManager tsm = env.getMasterServices().getAssignmentManager().getTableStateManager();
|
||||
if (!tsm.getTableState(tableName).equals(TableState.State.DISABLED)) {
|
||||
LOG.info("Table " + tableName + " isn't disabled; skipping enable");
|
||||
setFailure("master-enable-table", new TableNotDisabledException(this.tableName));
|
||||
TableState.State state = tsm.getTableState(tableName);
|
||||
if(!state.equals(TableState.State.DISABLED)){
|
||||
LOG.info("Table " + tableName + " isn't disabled;is "+state.name()+"; skipping enable");
|
||||
setFailure("master-enable-table", new TableNotDisabledException(
|
||||
this.tableName+" state is "+state.name()));
|
||||
canTableBeEnabled = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue