/** * Lookup table ID in ZK. Throw TableNotFoundException if not found. Also wraps * NamespaceNotFoundException in TableNotFoundException if namespace is not found. */ public static Table.ID getTableId(ClientContext context, String tableName) throws TableNotFoundException { try { return _getTableId(context, tableName); } catch (NamespaceNotFoundException e) { throw new TableNotFoundException(tableName, e); } }
public static String getTableName(ClientContext context, Table.ID tableId) throws TableNotFoundException { String tableName = getIdToNameMap(context).get(tableId); if (tableName == null) throw new TableNotFoundException(tableId.canonicalID(), null, null); return tableName; }
private void doTableFateOperation(String tableOrNamespaceName, Class<? extends Exception> namespaceNotFoundExceptionClass, FateOperation op, List<ByteBuffer> args, Map<String,String> opts) throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException { try { doFateOperation(op, args, opts, tableOrNamespaceName); } catch (NamespaceExistsException e) { // should not happen throw new AssertionError(e); } catch (NamespaceNotFoundException e) { if (namespaceNotFoundExceptionClass == null) { // should not happen throw new AssertionError(e); } else if (AccumuloException.class.isAssignableFrom(namespaceNotFoundExceptionClass)) { throw new AccumuloException("Cannot create table in non-existent namespace", e); } else if (TableNotFoundException.class.isAssignableFrom(namespaceNotFoundExceptionClass)) { throw new TableNotFoundException(null, tableOrNamespaceName, "Namespace not found", e); } else { // should not happen throw new AssertionError(e); } } }
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())); } }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = cl.getArgs()[0]; if (!shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.setTableName(tableName); return 0; }
@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.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.getAccumuloClient().tableOperations().addSplits(tableName, splits); return 0; }
} catch (Exception e) { if (!Tables.exists(context, tableId)) { throw new TableNotFoundException(tableId.canonicalID(), tableName, null);
public static String getTableOpt(final CommandLine cl, final Shell shellState) throws TableNotFoundException { String tableName; if (cl.hasOption(ShellOptions.tableOption)) { tableName = cl.getOptionValue(ShellOptions.tableOption); if (!shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist"); } } else { shellState.checkTableState(); tableName = shellState.getTableName(); } return tableName; }
/** * Returns the namespace id for a given table ID. * * @param context * The Accumulo client context * @param tableId * The tableId * @return The namespace id which this table resides in. * @throws IllegalArgumentException * if the table doesn't exist in ZooKeeper */ public static Namespace.ID getNamespaceId(ClientContext context, Table.ID tableId) throws TableNotFoundException { checkArgument(context != null, "instance is null"); checkArgument(tableId != null, "tableId is null"); ZooCache zc = getZooCache(context); byte[] n = zc.get(context.getZooKeeperRoot() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE); // We might get null out of ZooCache if this tableID doesn't exist if (n == null) { throw new TableNotFoundException(tableId.canonicalID(), null, null); } return Namespace.ID.of(new String(n, UTF_8)); } }
throw new TableNotFoundException(null, table, "while checking permissions");
/** * Lookup table ID in ZK. If not found, clears cache and tries again. */ public static Table.ID _getTableId(ClientContext context, String tableName) throws NamespaceNotFoundException, TableNotFoundException { Table.ID tableId = getNameToIdMap(context).get(tableName); if (tableId == null) { // maybe the table exist, but the cache was not updated yet... so try to clear the cache and // check again clearCache(context); tableId = getNameToIdMap(context).get(tableName); if (tableId == null) { String namespace = qualify(tableName).getFirst(); if (Namespaces.getNameToIdMap(context).containsKey(namespace)) throw new TableNotFoundException(null, tableName, null); else throw new NamespaceNotFoundException(null, namespace, null); } } return tableId; }
throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
@Override public Iterable<Entry<String,String>> getProperties(final String tableName) throws AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); try { return ServerClient.executeRaw(context, client -> client.getTableConfiguration(Tracer.traceInfo(), context.rpcCreds(), tableName)) .entrySet(); } catch (ThriftTableOperationException e) { switch (e.getType()) { case NOTFOUND: throw new TableNotFoundException(e); case NAMESPACE_NOTFOUND: throw new TableNotFoundException(tableName, new NamespaceNotFoundException(e)); default: throw new AccumuloException(e.description, e); } } catch (AccumuloException e) { throw e; } catch (Exception e) { throw new AccumuloException(e); } }
@Override public boolean testClassLoad(final String tableName, final String className, final String asTypeName) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { checkArgument(tableName != null, "tableName is null"); checkArgument(className != null, "className is null"); checkArgument(asTypeName != null, "asTypeName is null"); try { return ServerClient.executeRaw(context, client -> client.checkTableClass(Tracer.traceInfo(), context.rpcCreds(), tableName, className, asTypeName)); } catch (ThriftTableOperationException e) { switch (e.getType()) { case NOTFOUND: throw new TableNotFoundException(e); case NAMESPACE_NOTFOUND: throw new TableNotFoundException(tableName, new NamespaceNotFoundException(e)); default: throw new AccumuloException(e.description, e); } } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code, e); } catch (AccumuloException e) { throw e; } catch (Exception e) { throw new AccumuloException(e); } }
protected Table.ID getTableId(AccumuloClient client, String tableName) throws TableNotFoundException { TableOperations tops = client.tableOperations(); if (!client.tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } String tableId = null; while (tableId == null) { tableId = tops.tableIdMap().get(tableName); if (tableId == null) { sleepUninterruptibly(200, TimeUnit.MILLISECONDS); } } return Table.ID.of(tableId); }
switch (e.getType()) { case NAMESPACE_NOTFOUND: throw new TableNotFoundException(e.getTableName(), new NamespaceNotFoundException(e)); case NOTFOUND: throw new TableNotFoundException(e); default: throw new AccumuloException(e);
switch (e.getType()) { case NAMESPACE_NOTFOUND: throw new TableNotFoundException(e.getTableName(), new NamespaceNotFoundException(e)); case NOTFOUND: throw new TableNotFoundException(e); default: throw new AccumuloException(e);
throw new TableNotFoundException(tableId.canonicalID(), tableName, null); if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId));
throw new TableNotFoundException(null, tableName, "Namespace not found", e);
switch (e.getType()) { case NOTFOUND: throw new TableNotFoundException(e); case NAMESPACE_NOTFOUND: throw new TableNotFoundException(e.getTableName(), new NamespaceNotFoundException(e)); default: throw new AccumuloException(e.description, e);