use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class TableOperationsImpl method locate.
@Override
public Locations locate(String tableName, Collection<Range> ranges) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
EXISTING_TABLE_NAME.validate(tableName);
requireNonNull(ranges, "ranges must be non null");
TableId tableId = context.getTableId(tableName);
TabletLocator locator = TabletLocator.getLocator(context, tableId);
List<Range> rangeList = null;
if (ranges instanceof List) {
rangeList = (List<Range>) ranges;
} else {
rangeList = new ArrayList<>(ranges);
}
Map<String, Map<KeyExtent, List<Range>>> binnedRanges = new HashMap<>();
locator.invalidateCache();
Retry retry = Retry.builder().infiniteRetries().retryAfter(100, MILLISECONDS).incrementBy(100, MILLISECONDS).maxWait(2, SECONDS).backOffFactor(1.5).logInterval(3, MINUTES).createRetry();
while (!locator.binRanges(context, rangeList, binnedRanges).isEmpty()) {
context.requireTableExists(tableId, tableName);
context.requireNotOffline(tableId, tableName);
binnedRanges.clear();
try {
retry.waitForNextAttempt();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
locator.invalidateCache();
}
return new LocationsImpl(binnedRanges);
}
use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class TableOperationsImpl method offline.
@Override
public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
EXISTING_TABLE_NAME.validate(tableName);
TableId tableId = context.getTableId(tableName);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.canonical().getBytes(UTF_8)));
Map<String, String> opts = new HashMap<>();
try {
doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_OFFLINE, args, opts);
} catch (TableExistsException e) {
// should not happen
throw new AssertionError(e);
}
if (wait)
waitForTableStateTransition(tableId, TableState.OFFLINE);
}
use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class TableOperationsImpl method cancelCompaction.
@Override
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
EXISTING_TABLE_NAME.validate(tableName);
TableId tableId = context.getTableId(tableName);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.canonical().getBytes(UTF_8)));
Map<String, String> opts = new HashMap<>();
try {
doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_CANCEL_COMPACT, args, opts);
} catch (TableExistsException e) {
// should not happen
throw new AssertionError(e);
}
}
use of org.apache.accumulo.core.data.TableId 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.data.TableId in project accumulo by apache.
the class TableOperationsImpl method online.
@Override
public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
EXISTING_TABLE_NAME.validate(tableName);
TableId tableId = context.getTableId(tableName);
/**
* ACCUMULO-4574 if table is already online return without executing fate operation.
*/
if (isOnline(tableName)) {
if (wait)
waitForTableStateTransition(tableId, TableState.ONLINE);
return;
}
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.canonical().getBytes(UTF_8)));
Map<String, String> opts = new HashMap<>();
try {
doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_ONLINE, args, opts);
} catch (TableExistsException e) {
// should not happen
throw new AssertionError(e);
}
if (wait)
waitForTableStateTransition(tableId, TableState.ONLINE);
}
Aggregations