/** * 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); } }
@Override public Status delete(String table, String key) { BatchWriter bw; try { bw = getWriter(table); } catch (TableNotFoundException e) { System.err.println("Error trying to connect to Accumulo table."); e.printStackTrace(); return Status.ERROR; } try { deleteRow(table, new Text(key), bw); } catch (TableNotFoundException | MutationsRejectedException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } catch (RuntimeException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } return Status.OK; }
public static void executeNamespace(ClientContext context, ClientExec<MasterClientService.Client> exec) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException { try { executeGeneric(context, exec); } catch (TableNotFoundException e) { if (e.getCause() instanceof NamespaceNotFoundException) throw (NamespaceNotFoundException) e.getCause(); } }
@Override public void flush(String tableName) throws AccumuloException, AccumuloSecurityException { try { flush(tableName, null, null, false); } catch (TableNotFoundException e) { throw new AccumuloException(e.getMessage(), e); } }
/** * Write the given Mutation to the replication table. */ static void update(ClientContext context, Mutation m, KeyExtent extent) { Writer t = getWriter(context); while (true) { try { t.update(m); return; } catch (AccumuloException e) { log.error(e.toString(), e); } catch (AccumuloSecurityException e) { log.error(e.toString(), e); } catch (ConstraintViolationException e) { log.error(e.toString(), e); } catch (TableNotFoundException e) { log.error(e.toString(), e); } sleepUninterruptibly(1, TimeUnit.SECONDS); } }
} catch (TableNotFoundException e) { LoggerFactory.getLogger(ShellPluginConfigurationCommand.class) .error("Table not found: {} {}", tableName, e.getMessage()); return null; } catch (Exception e) {
@Override public void clearLocatorCache(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { getConnector(login).tableOperations().clearLocatorCache(tableName); } catch (TableNotFoundException e) { throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString()); } catch (Exception e) { throw new TException(e.toString()); } }
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 Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getContext(), tableId); } catch (TableNotFoundException e) { throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; }
@Override public Status delete(String table, String key) { BatchWriter bw; try { bw = getWriter(table); } catch (TableNotFoundException e) { System.err.println("Error trying to connect to Accumulo table."); e.printStackTrace(); return Status.ERROR; } try { deleteRow(table, new Text(key), bw); } catch (TableNotFoundException | MutationsRejectedException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } catch (RuntimeException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } return Status.OK; }
public static void executeNamespace(ClientContext context, ClientExec<MasterClientService.Client> exec) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException { try { executeGeneric(context, exec); } catch (TableNotFoundException e) { if (e.getCause() instanceof NamespaceNotFoundException) throw (NamespaceNotFoundException) e.getCause(); } }
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); } } }
private Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getContext(), tableId); } catch (TableNotFoundException e) { throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; }
@Override public Status delete(String table, String key) { BatchWriter bw; try { bw = getWriter(table); } catch (TableNotFoundException e) { System.err.println("Error trying to connect to Accumulo table."); e.printStackTrace(); return Status.ERROR; } try { deleteRow(table, new Text(key), bw); } catch (TableNotFoundException | MutationsRejectedException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } catch (RuntimeException e) { System.err.println("Error performing delete."); e.printStackTrace(); return Status.ERROR; } return Status.OK; }
log.debug("Rename " + srcTableName + " failed, " + newTableName + " exists"); } catch (TableNotFoundException e) { Throwable cause = e.getCause(); if (null != cause) {
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 @Deprecated public void flush(String tableName) throws AccumuloException, AccumuloSecurityException { try { flush(tableName, null, null, false); } catch (TableNotFoundException e) { throw new AccumuloException(e.getMessage(), e); } }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { BatchWriter bw = null; try { bw = getWriter(table); } catch (TableNotFoundException e) { System.err.println("Error opening batch writer to Accumulo table " + table); e.printStackTrace(); return Status.ERROR; } Mutation mutInsert = new Mutation(key.getBytes(UTF_8)); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { mutInsert.put(colFamBytes, entry.getKey().getBytes(UTF_8), entry.getValue().toArray()); } try { bw.addMutation(mutInsert); } catch (MutationsRejectedException e) { System.err.println("Error performing update."); e.printStackTrace(); return Status.ERROR; } return Status.BATCHED_OK; }
c.tableOperations().delete(t1); } catch (TableNotFoundException e) { assertEquals(NamespaceNotFoundException.class.getName(), e.getCause().getClass().getName());
@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; }