@Override public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); _flush(tableId, start, end, wait); }
public static String getPrintableTableInfoFromName(ClientContext context, String tableName) { Table.ID tableId = null; try { tableId = getTableId(context, tableName); } catch (TableNotFoundException e) { // handled in the string formatting } return tableId == null ? String.format("%s(?)", tableName) : String.format("%s(ID:%s)", tableName, tableId.canonicalID()); }
@Override public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException { Table.ID tableId = Tables.getTableId(context, tableName); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); 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); } }
/** * Returns the table ID for the given table name. * * @param tableName * The name of the table which to find the ID for * @return The table ID, or null if the table name doesn't exist */ private Table.ID getId(String tableName) throws TableNotFoundException { try { return Tables.getTableId(context, tableName); } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); log.error("Unexpected exception when fetching table id for {}", tableName); if (cause == null) { throw new RuntimeException(e); } else if (cause instanceof TableNotFoundException) { throw (TableNotFoundException) cause; } else if (cause instanceof TableOfflineException) { throw (TableOfflineException) cause; } throw e; } }
@Override public void clearLocatorCache(String tableName) throws TableNotFoundException { checkArgument(tableName != null, "tableName is null"); TabletLocator tabLocator = TabletLocator.getLocator(context, Tables.getTableId(context, tableName)); tabLocator.invalidateCache(); }
@Override @Deprecated public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException { checkArgument(tableName != null, "tableName is null"); checkArgument(dir != null, "dir is null"); checkArgument(failureDir != null, "failureDir is null"); // check for table existence Tables.getTableId(context, tableName); Path dirPath = checkPath(dir, "Bulk", ""); Path failPath = checkPath(failureDir, "Bulk", "failure"); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(UTF_8)), ByteBuffer.wrap(dirPath.toString().getBytes(UTF_8)), ByteBuffer.wrap(failPath.toString().getBytes(UTF_8)), ByteBuffer.wrap((setTime + "").getBytes(UTF_8))); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_BULK_IMPORT, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } }
@Override public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException { checkArgument(srcTableName != null, "srcTableName is null"); checkArgument(newTableName != null, "newTableName is null"); Table.ID srcTableId = Tables.getTableId(context, srcTableName); if (flush) _flush(srcTableId, null, null, true); if (propertiesToExclude == null) propertiesToExclude = Collections.emptySet(); if (propertiesToSet == null) propertiesToSet = Collections.emptyMap(); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(srcTableId.getUtf8()), ByteBuffer.wrap(newTableName.getBytes(UTF_8))); Map<String,String> opts = new HashMap<>(); for (Entry<String,String> entry : propertiesToSet.entrySet()) { if (entry.getKey().startsWith(CLONE_EXCLUDE_PREFIX)) throw new IllegalArgumentException("Property can not start with " + CLONE_EXCLUDE_PREFIX); opts.put(entry.getKey(), entry.getValue()); } for (String prop : propertiesToExclude) { opts.put(CLONE_EXCLUDE_PREFIX + prop, ""); } doTableFateOperation(newTableName, AccumuloException.class, FateOperation.TABLE_CLONE, args, opts); }
@Override public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); 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); }
public static void printDiskUsage(Collection<String> tableNames, VolumeManager fs, AccumuloClient client, Printer printer, boolean humanReadable) throws TableNotFoundException, IOException { HashSet<Table.ID> tableIds = new HashSet<>(); // Get table IDs for all tables requested to be 'du' for (String tableName : tableNames) { Table.ID tableId = Tables.getTableId((ClientContext) client, tableName); if (tableId == null) throw new TableNotFoundException(null, tableName, "Table " + tableName + " not found"); tableIds.add(tableId); } Map<TreeSet<String>,Long> usage = getDiskUsage(tableIds, fs, client); String valueFormat = humanReadable ? "%9s" : "%,24d"; for (Entry<TreeSet<String>,Long> entry : usage.entrySet()) { Object value = humanReadable ? NumUtil.bigNumberForSize(entry.getValue()) : entry.getValue(); printer.print(String.format(valueFormat + " %s", value, entry.getKey())); } }
static int checkTable(ServerContext context, String tableName, boolean fix) throws Exception { if (tableName.equals(RootTable.NAME)) { throw new IllegalArgumentException("Can not check root table"); } else if (tableName.equals(MetadataTable.NAME)) { return checkTable(context, RootTable.NAME, MetadataSchema.TabletsSection.getRange(), fix); } else { Table.ID tableId = Tables.getTableId(context, tableName); Range range = new KeyExtent(tableId, null, null).toMetadataRange(); return checkTable(context, MetadataTable.NAME, range, fix); } }
Table.ID getTableId(String tableName) throws TableNotFoundException { Table.ID tableId = Tables.getTableId(this, tableName); if (Tables.getTableState(this, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(this, tableId)); return tableId; }
@Override public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); /** * ACCUMULO-4574 if table is already online return without executing fate operation. */ TableState expectedState = Tables.getTableState(context, tableId, true); if (expectedState == TableState.ONLINE) { if (wait) waitForTableStateTransition(tableId, TableState.ONLINE); return; } List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); 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); }
Table.ID tableId = Tables.getTableId(context, tableName);
@Override public void load() throws TableNotFoundException, IOException, AccumuloException, AccumuloSecurityException { Table.ID tableId = Tables.getTableId(context, tableName); Map<String,String> props = context.instanceOperations().getSystemConfiguration(); AccumuloConfiguration conf = new ConfigurationCopy(props); FileSystem fs = VolumeConfiguration.getVolume(dir, context.getHadoopConf(), conf) .getFileSystem(); Path srcPath = checkPath(fs, dir); SortedMap<KeyExtent,Bulk.Files> mappings; if (plan == null) { mappings = computeMappingFromFiles(fs, tableId, srcPath); } else { mappings = computeMappingFromPlan(fs, tableId, srcPath); } BulkSerialize.writeLoadMapping(mappings, srcPath.toString(), fs::create); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8()), ByteBuffer.wrap(srcPath.toString().getBytes(UTF_8)), ByteBuffer.wrap((setTime + "").getBytes(UTF_8))); new TableOperationsImpl(context).doBulkFateOperation(args, tableName); }
protected Iterator<Size> getSizeIterator(AccumuloClient client, String tablename, Text start, Text end) throws MergeException { // open up metadata, walk through the tablets. Table.ID tableId; TabletsMetadata tablets; try { ClientContext context = (ClientContext) client; tableId = Tables.getTableId(context, tablename); tablets = TabletsMetadata.builder().scanMetadataTable() .overRange(new KeyExtent(tableId, end, start).toMetadataRange()).fetchFiles().fetchPrev() .build(context); } catch (Exception e) { throw new MergeException(e); } return tablets.stream().map(tm -> { long size = tm.getFilesMap().values().stream().mapToLong(DataFileValue::getSize).sum(); return new Size(tm.getExtent(), size); }).iterator(); }
Table.ID tableId = Tables.getTableId(context, tableName); range = new KeyExtent(tableId, null, null).toMetadataRange();
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException { String old = cl.getArgs()[0]; String newer = cl.getArgs()[1]; boolean resetContext = false; Table.ID currentTableId = null; if (!(shellState.getTableName() == null) && !shellState.getTableName().isEmpty()) { Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), old); List<Table.ID> tableIds = Namespaces.getTableIds(shellState.getContext(), namespaceId); currentTableId = Tables.getTableId(shellState.getContext(), shellState.getTableName()); resetContext = tableIds.contains(currentTableId); } shellState.getAccumuloClient().namespaceOperations().rename(old, newer); if (resetContext) { shellState.setTableName(Tables.getTableName(shellState.getContext(), currentTableId)); } return 0; }
Table.ID tableId = Tables.getTableId(context, tableName);
requireNonNull(ranges, "ranges must be non null"); Table.ID tableId = Tables.getTableId(context, tableName); TabletLocator locator = TabletLocator.getLocator(context, tableId);
@Override public List<Summary> retrieve() throws AccumuloException, AccumuloSecurityException, TableNotFoundException { Table.ID tableId = Tables.getTableId(context, tableName); if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId)); TRowRange range = new TRowRange(TextUtil.getByteBuffer(startRow), TextUtil.getByteBuffer(endRow)); TSummaryRequest request = new TSummaryRequest(tableId.canonicalID(), range, summariesToFetch, summarizerClassRegex); if (flush) { _flush(tableId, startRow, endRow, true); } TSummaries ret = ServerClient.execute(context, new TabletClientService.Client.Factory(), client -> { TSummaries tsr = client.startGetSummaries(Tracer.traceInfo(), context.rpcCreds(), request); while (!tsr.finished) { tsr = client.contiuneGetSummaries(Tracer.traceInfo(), tsr.sessionId); } return tsr; }); return new SummaryCollection(ret).getSummaries(); }