Search in sources :

Example 1 with TableState

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;
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TableState(org.apache.accumulo.core.manager.state.tables.TableState)

Example 2 with TableState

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);
    }
}
Also used : TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) TableState(org.apache.accumulo.core.manager.state.tables.TableState)

Example 3 with TableState

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;
}
Also used : TableState(org.apache.accumulo.core.manager.state.tables.TableState)

Example 4 with TableState

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);
}
Also used : ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) TableState(org.apache.accumulo.core.manager.state.tables.TableState)

Example 5 with 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);
    }
}
Also used : NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) KeeperException(org.apache.zookeeper.KeeperException) TableState(org.apache.accumulo.core.manager.state.tables.TableState)

Aggregations

TableState (org.apache.accumulo.core.manager.state.tables.TableState)10 TableId (org.apache.accumulo.core.data.TableId)4 TableManager (org.apache.accumulo.server.tables.TableManager)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)1 TabletLocation (org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocation)1 Range (org.apache.accumulo.core.data.Range)1 Constraint (org.apache.accumulo.core.data.constraints.Constraint)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 TRowRange (org.apache.accumulo.core.dataImpl.thrift.TRowRange)1 ManagerMonitorInfo (org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)1 TabletMetadata (org.apache.accumulo.core.metadata.schema.TabletMetadata)1