use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.
the class AddSplitsCommand method execute.
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
final String tableName = OptUtil.getTableOpt(cl, shellState);
final boolean decode = cl.hasOption(base64Opt.getOpt());
final TreeSet<Text> splits = new TreeSet<>();
if (cl.hasOption(optSplitsFile.getOpt())) {
splits.addAll(ShellUtil.scanFile(cl.getOptionValue(optSplitsFile.getOpt()), decode));
} else {
if (cl.getArgList().isEmpty()) {
throw new MissingArgumentException("No split points specified");
}
for (String s : cl.getArgs()) {
splits.add(new Text(s.getBytes(Shell.CHARSET)));
}
}
if (!shellState.getConnector().tableOperations().exists(tableName)) {
throw new TableNotFoundException(null, tableName, null);
}
shellState.getConnector().tableOperations().addSplits(tableName, splits);
return 0;
}
use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.
the class MockTableOperations method rename.
@Override
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException {
if (!exists(oldTableName))
throw new TableNotFoundException(oldTableName, oldTableName, "");
if (exists(newTableName))
throw new TableExistsException(newTableName, newTableName, "");
MockTable t = acu.tables.remove(oldTableName);
String namespace = Tables.qualify(newTableName).getFirst();
MockNamespace n = acu.namespaces.get(namespace);
if (n == null) {
n = new MockNamespace();
}
t.setNamespaceName(namespace);
t.setNamespace(n);
acu.namespaces.put(namespace, n);
acu.tables.put(newTableName, t);
}
use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.
the class MockTableOperations method deleteRows.
@Override
public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
MockTable t = acu.tables.get(tableName);
Text startText = start != null ? new Text(start) : new Text();
if (startText.getLength() == 0 && end == null) {
t.table.clear();
return;
}
Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
startText.append(ZERO, 0, 1);
endText.append(ZERO, 0, 1);
Set<Key> keep = new TreeSet<>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
t.table.keySet().removeAll(keep);
}
use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.
the class TabletGroupWatcher method deleteTablets.
private void deleteTablets(MergeInfo info) throws AccumuloException {
KeyExtent extent = info.getExtent();
String targetSystemTable = extent.isMeta() ? RootTable.NAME : MetadataTable.NAME;
Master.log.debug("Deleting tablets for {}", extent);
char timeType = '\0';
KeyExtent followingTablet = null;
if (extent.getEndRow() != null) {
Key nextExtent = new Key(extent.getEndRow()).followingKey(PartialKey.ROW);
followingTablet = getHighTablet(new KeyExtent(extent.getTableId(), nextExtent.getRow(), extent.getEndRow()));
Master.log.debug("Found following tablet {}", followingTablet);
}
try {
Connector conn = this.master.getConnector();
Text start = extent.getPrevEndRow();
if (start == null) {
start = new Text();
}
Master.log.debug("Making file deletion entries for {}", extent);
Range deleteRange = new Range(KeyExtent.getMetadataEntry(extent.getTableId(), start), false, KeyExtent.getMetadataEntry(extent.getTableId(), extent.getEndRow()), true);
Scanner scanner = conn.createScanner(targetSystemTable, Authorizations.EMPTY);
scanner.setRange(deleteRange);
TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(scanner);
TabletsSection.ServerColumnFamily.TIME_COLUMN.fetch(scanner);
scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
Set<FileRef> datafiles = new TreeSet<>();
for (Entry<Key, Value> entry : scanner) {
Key key = entry.getKey();
if (key.compareColumnFamily(DataFileColumnFamily.NAME) == 0) {
datafiles.add(new FileRef(this.master.fs, key));
if (datafiles.size() > 1000) {
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
datafiles.clear();
}
} else if (TabletsSection.ServerColumnFamily.TIME_COLUMN.hasColumns(key)) {
timeType = entry.getValue().toString().charAt(0);
} else if (key.compareColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
throw new IllegalStateException("Tablet " + key.getRow() + " is assigned during a merge!");
} else if (TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.hasColumns(key)) {
// ACCUMULO-2974 Need to include the TableID when converting a relative path to an absolute path.
// The value has the leading path separator already included so it doesn't need it included.
String path = entry.getValue().toString();
if (path.contains(":")) {
datafiles.add(new FileRef(path));
} else {
datafiles.add(new FileRef(path, this.master.fs.getFullPath(FileType.TABLE, Path.SEPARATOR + extent.getTableId() + path)));
}
if (datafiles.size() > 1000) {
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
datafiles.clear();
}
}
}
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
BatchWriter bw = conn.createBatchWriter(targetSystemTable, new BatchWriterConfig());
try {
deleteTablets(info, deleteRange, bw, conn);
} finally {
bw.close();
}
if (followingTablet != null) {
Master.log.debug("Updating prevRow of {} to {}", followingTablet, extent.getPrevEndRow());
bw = conn.createBatchWriter(targetSystemTable, new BatchWriterConfig());
try {
Mutation m = new Mutation(followingTablet.getMetadataEntry());
TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, KeyExtent.encodePrevEndRow(extent.getPrevEndRow()));
ChoppedColumnFamily.CHOPPED_COLUMN.putDelete(m);
bw.addMutation(m);
bw.flush();
} finally {
bw.close();
}
} else {
// Recreate the default tablet to hold the end of the table
Master.log.debug("Recreating the last tablet to point to {}", extent.getPrevEndRow());
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(extent.getTableId());
String tdir = master.getFileSystem().choose(chooserEnv, ServerConstants.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + extent.getTableId() + Constants.DEFAULT_TABLET_LOCATION;
MetadataTableUtil.addTablet(new KeyExtent(extent.getTableId(), null, extent.getPrevEndRow()), tdir, master, timeType, this.master.masterLock);
}
} catch (RuntimeException | IOException | TableNotFoundException | AccumuloSecurityException ex) {
throw new AccumuloException(ex);
}
}
use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.
the class StatusMaker method deleteStatusRecord.
/**
* Because there is only one active Master, and thus one active StatusMaker, the only safe time that we can issue the delete for a Status which is closed is
* immediately after writing it to the replication table.
* <p>
* If we try to defer and delete these entries in another thread/process, we will have no assurance that the Status message was propagated to the replication
* table. It is easiest, in terms of concurrency, to do this all in one step.
*
* @param k
* The Key to delete
*/
protected void deleteStatusRecord(Key k) {
log.debug("Deleting {} from metadata table as it's no longer needed", k.toStringNoTruncate());
if (null == metadataWriter) {
try {
metadataWriter = conn.createBatchWriter(sourceTableName, new BatchWriterConfig());
} catch (TableNotFoundException e) {
throw new RuntimeException("Metadata table doesn't exist");
}
}
try {
Mutation m = new Mutation(k.getRow());
m.putDelete(k.getColumnFamily(), k.getColumnQualifier());
metadataWriter.addMutation(m);
metadataWriter.flush();
} catch (MutationsRejectedException e) {
log.warn("Failed to delete status mutations for metadata table, will retry", e);
}
}
Aggregations