public boolean exists(String table) { return connector.tableOperations().exists(table); }
private void flush() { try { final BatchWriter writer = this.writer.get(); if (writer != null) { writer.flush(); } else { // We don't have a writer. If the table exists, try to make a new writer. if (accumuloClient.tableOperations().exists(tableName)) { resetWriter(); } } } catch (MutationsRejectedException | RuntimeException exception) { log.warn("Problem flushing traces, resetting writer. Set log level to" + " DEBUG to see stacktrace. cause: " + exception); log.debug("flushing traces failed due to exception", exception); resetWriter(); /* XXX e.g. if the writer was closed between when we grabbed it and when we called flush. */ } }
@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; }
public void addTable(Text tableName) throws AccumuloException, AccumuloSecurityException { if (simulate) { log.info("Simulating adding table: " + tableName); return; } log.debug("Adding table: " + tableName); BatchWriter bw = null; String table = tableName.toString(); if (createTables && !client.tableOperations().exists(table)) { try { client.tableOperations().create(table); } catch (AccumuloSecurityException e) { log.error("Accumulo security violation creating " + table, e); throw e; } catch (TableExistsException e) { // Shouldn't happen } } try { bw = mtbw.getBatchWriter(table); } catch (TableNotFoundException e) { log.error("Accumulo table " + table + " doesn't exist and cannot be created.", e); throw new AccumuloException(e); } catch (AccumuloException | AccumuloSecurityException e) { throw e; } if (bw != null) bws.put(tableName, bw); }
public void addTable(Text tableName) throws AccumuloException, AccumuloSecurityException { if (simulate) { log.info("Simulating adding table: " + tableName); return; } log.debug("Adding table: " + tableName); BatchWriter bw = null; String table = tableName.toString(); if (createTables && !client.tableOperations().exists(table)) { try { client.tableOperations().create(table); } catch (AccumuloSecurityException e) { log.error("Accumulo security violation creating " + table, e); throw e; } catch (TableExistsException e) { // Shouldn't happen } } try { bw = mtbw.getBatchWriter(table); } catch (TableNotFoundException e) { log.error("Accumulo table " + table + " doesn't exist and cannot be created.", e); throw new AccumuloException(e); } catch (AccumuloException | AccumuloSecurityException e) { throw e; } if (bw != null) bws.put(tableName, bw); }
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; }
if (!shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
break; if (!shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null);
private Scanner getScanner(AccumuloClient client) throws AccumuloException { try { AccumuloConfiguration conf = Monitor.getContext().getConfiguration(); final String table = conf.get(Property.TRACE_TABLE); if (!client.tableOperations().exists(table)) { return null; } return client.createScanner(table); } catch (AccumuloSecurityException | TableNotFoundException ex) { return null; } }
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); }
if (shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableExistsException(null, tableName, null); } else if (cl.hasOption(createTableOptCopySplits.getOpt())) { final String oldTable = cl.getOptionValue(createTableOptCopySplits.getOpt()); if (!shellState.getAccumuloClient().tableOperations().exists(oldTable)) { throw new TableNotFoundException(null, oldTable, null); if (!shellState.getAccumuloClient().tableOperations().exists(oldTable)) { throw new TableNotFoundException(null, oldTable, null); if (shellState.getAccumuloClient().tableOperations().exists(tableName)) { final Iterable<Entry<String,String>> configuration = shellState.getAccumuloClient() .tableOperations().getProperties(cl.getOptionValue(createTableOptCopyConfig.getOpt()));
if (tableName != null && !shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null);
.build(); if (!accumuloClient.tableOperations().exists(tableName)) { accumuloClient.tableOperations().create(tableName); IteratorSetting setting = new IteratorSetting(10, "ageoff", AgeOffFilter.class.getName());
public void start(String[] args) throws MergeException { Opts opts = new Opts(); opts.parseArgs(Merge.class.getName(), args); try (AccumuloClient client = opts.createClient()) { if (!client.tableOperations().exists(opts.getTableName())) { System.err.println("table " + opts.getTableName() + " does not exist"); return; } if (opts.goalSize == null || opts.goalSize < 1) { AccumuloConfiguration tableConfig = new ConfigurationCopy( client.tableOperations().getProperties(opts.getTableName())); opts.goalSize = tableConfig.getAsBytes(Property.TABLE_SPLIT_THRESHOLD); } message("Merging tablets in table %s to %d bytes", opts.getTableName(), opts.goalSize); mergomatic(client, opts.getTableName(), opts.begin, opts.end, opts.goalSize, opts.force); } catch (Exception ex) { throw new MergeException(ex); } }
private void dropTableIfExists(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (this.connector.tableOperations().exists(tableName)) { this.connector.tableOperations().delete(tableName); } }
@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.getConnector().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.setTableName(tableName); return 0; }
public boolean accumuloTableExists() { if (!config.hasRequiredAdminProps()) { throw new IllegalArgumentException("Admin configuration is missing required properties"); } AccumuloClient client = AccumuloUtil.getClient(config); return client.tableOperations().exists(config.getAccumuloTable()); } }
@Override public BatchWriter createBatchWriter(String tableName, BatchWriterConfig config) throws TableNotFoundException { if (!tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } try { return new ProxyBatchWriter(this, token, tableName, config); } catch (TException e) { throw ExceptionFactory.runtimeException(e); } }
private void recreateTable(TableOperations tops, String table) throws Exception { if (tops.exists(table)) { tops.delete(table); } tops.create(table); }