use of org.apache.accumulo.core.manager.state.tables.TableState in project accumulo by apache.
the class TableOperationsImpl method isOnline.
@Override
public boolean isOnline(String tableName) throws AccumuloException, TableNotFoundException {
EXISTING_TABLE_NAME.validate(tableName);
TableId tableId = context.getTableId(tableName);
TableState expectedState = context.getTableState(tableId, true);
return expectedState == TableState.ONLINE;
}
use of org.apache.accumulo.core.manager.state.tables.TableState in project accumulo by apache.
the class TabletGroupWatcher method cancelOfflineTableMigrations.
private void cancelOfflineTableMigrations(KeyExtent extent) {
TServerInstance dest = manager.migrations.get(extent);
TableState tableState = manager.getTableManager().getTableState(extent.tableId());
if (dest != null && tableState == TableState.OFFLINE) {
manager.migrations.remove(extent);
}
}
use of org.apache.accumulo.core.manager.state.tables.TableState in project accumulo by apache.
the class ChangeTableState method call.
@Override
public Repo<Manager> call(long tid, Manager env) {
TableState ts = TableState.ONLINE;
if (top == TableOperation.OFFLINE)
ts = TableState.OFFLINE;
env.getTableManager().transitionTableState(tableId, ts);
Utils.unreserveNamespace(env, namespaceId, tid, false);
Utils.unreserveTable(env, tableId, tid, true);
LoggerFactory.getLogger(ChangeTableState.class).debug("Changed table state {} {}", tableId, ts);
env.getEventCoordinator().event("Set table state of %s to %s", tableId, ts);
return null;
}
use of org.apache.accumulo.core.manager.state.tables.TableState in project accumulo by apache.
the class CloneTestIT method assertTableState.
private void assertTableState(String tableName, AccumuloClient c, TableState expected) {
String tableId = c.tableOperations().tableIdMap().get(tableName);
TableState tableState = ((ClientContext) c).getTableState(TableId.of(tableId));
assertEquals(expected, tableState);
}
use of org.apache.accumulo.core.manager.state.tables.TableState in project accumulo by apache.
the class TableManager method transitionTableState.
public synchronized void transitionTableState(final TableId tableId, final TableState newState) {
Preconditions.checkArgument(newState != TableState.UNKNOWN);
String statePath = zkRoot + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE;
try {
zoo.mutateOrCreate(statePath, newState.name().getBytes(UTF_8), oldData -> {
TableState oldState = TableState.UNKNOWN;
if (oldData != null)
oldState = TableState.valueOf(new String(oldData, UTF_8));
// this check makes the transition operation idempotent
if (oldState == newState)
// already at desired state, so nothing to do
return null;
boolean transition = true;
// NEW -> (ONLINE|OFFLINE)+--- DELETING
switch(oldState) {
case NEW:
transition = (newState == TableState.OFFLINE || newState == TableState.ONLINE);
break;
// fall-through intended
case ONLINE:
// fall through intended
case UNKNOWN:
case OFFLINE:
transition = (newState != TableState.NEW);
break;
case DELETING:
// Can't transition to any state from DELETING
transition = false;
break;
}
if (!transition)
throw new IllegalTableTransitionException(oldState, newState);
log.debug("Transitioning state for table {} from {} to {}", tableId, oldState, newState);
return newState.name().getBytes(UTF_8);
});
} catch (Exception e) {
log.error("FATAL Failed to transition table to state {}", newState);
throw new RuntimeException(e);
}
}
Aggregations