@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") private void printTableConfiguration(AccumuloClient accumuloClient, String tableName, File outputDirectory) throws AccumuloException, TableNotFoundException, IOException { File tableBackup = new File(outputDirectory, tableName + ".cfg"); FileWriter writer = new FileWriter(tableBackup); writer.write(createTableFormat.format(new String[] {tableName})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : accumuloClient.tableOperations().getProperties(tableName)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> prop : props.entrySet()) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (defaultValue == null || !defaultValue.equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { writer.write(configFormat .format(new String[] {tableName, prop.getKey() + "=" + prop.getValue()})); } } } } writer.close(); } }
Iterator<Entry<String,String>> props; try { props = shellState.getAccumuloClient().tableOperations().getProperties(tableName).iterator(); } catch (AccumuloException | TableNotFoundException e) { return null;
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); if (cl.hasOption(removePluginOption.getOpt())) { // Remove the property removePlugin(cl, shellState, tableName); shellState.getReader().println("Removed " + pluginType + " on " + tableName); } else if (cl.hasOption(listPluginOption.getOpt())) { // Get the options for this table final Iterator<Entry<String,String>> iter = shellState.getAccumuloClient().tableOperations() .getProperties(tableName).iterator(); while (iter.hasNext()) { Entry<String,String> ent = iter.next(); // List all parameters with the property name if (ent.getKey().startsWith(tableProp.toString())) { shellState.getReader().println(ent.getKey() + ": " + ent.getValue()); } } } else { // Set the plugin with the provided options String className = cl.getOptionValue(pluginClassOption.getOpt()); // Set the plugin property on the table setPlugin(cl, shellState, tableName, className); } return 0; }
properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e);
propertiesForTable = tops.getProperties(table); } catch (TableNotFoundException e) { log.warn("Could not fetch properties for {}", table, e);
if (shellState.getAccumuloClient().tableOperations().exists(tableName)) { final Iterable<Entry<String,String>> configuration = shellState.getAccumuloClient() .tableOperations().getProperties(cl.getOptionValue(createTableOptCopyConfig.getOpt())); for (Entry<String,String> entry : configuration) { if (Property.isValidTablePropertyKey(entry.getKey())) {
.getProperties(OptUtil.getTableOpt(cl, shellState)); } else { throw new IllegalArgumentException("No table or namespace specified");
.getSystemConfiguration().entrySet(); if (tableName != null) { acuconf = shellState.getAccumuloClient().tableOperations().getProperties(tableName); } else if (namespace != null) { acuconf = shellState.getAccumuloClient().namespaceOperations().getProperties(namespace);
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); } }
context.tableOperations().getProperties(tableName));
private void ensureDeletesAreDisabled() { String value = null; Iterable<Entry<String, String>> props; try { props = client.tableOperations().getProperties(table); } catch (AccumuloException | TableNotFoundException e) { throw new IllegalStateException(e); } for (Entry<String, String> entry : props) { if (entry.getKey().equals(AccumuloProps.TABLE_DELETE_BEHAVIOR)) { value = entry.getValue(); } } Preconditions.checkState(AccumuloProps.TABLE_DELETE_BEHAVIOR_VALUE.equals(value), "The Accumulo table %s is not configured correctly. Please set %s=%s for this table in Accumulo.", table, AccumuloProps.TABLE_DELETE_BEHAVIOR, AccumuloProps.TABLE_DELETE_BEHAVIOR_VALUE); }
protected void checkTableForProperty(TableOperations tops, String tableName, String expectedKey, String expectedValue) throws Exception { for (int i = 0; i < 5; i++) { for (Entry<String,String> entry : tops.getProperties(tableName)) { if (expectedKey.equals(entry.getKey())) { assertEquals(expectedValue, entry.getValue()); return; } } Thread.sleep(500); } fail("Failed to find expected property on " + tableName + ": " + expectedKey + "=" + expectedValue); }
public int numProperties(Connector connector, String tableName) throws AccumuloException, TableNotFoundException { return Iterators.size(connector.tableOperations().getProperties(tableName).iterator()); }
@Override public Map<String,String> getTableProperties(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { Map<String,String> ret = new HashMap<>(); for (Map.Entry<String,String> entry : getConnector(login).tableOperations() .getProperties(tableName)) { ret.put(entry.getKey(), entry.getValue()); } return ret; } catch (Exception e) { handleExceptionTNF(e); return null; } }
private boolean checkHasProperty(String name, String propKey, String propVal, boolean nameIsTable) { try { Iterable<Entry<String,String>> iterable = nameIsTable ? c.tableOperations().getProperties(name) : c.namespaceOperations().getProperties(name); for (Entry<String,String> e : iterable) if (propKey.equals(e.getKey())) return propVal.equals(e.getValue()); return false; } catch (Exception e) { fail(); return false; } }
public TablePropertiesMap(TableOperations tops, String tableName) throws AccumuloException, TableNotFoundException { for (Map.Entry<String,String> entry : tops.getProperties(tableName)) { put(entry.getKey(), entry.getValue()); } } }
/** * Gets the configuration specific to a table. * * @param conn * connector (used to find table name) * @param tableId * table ID * @return configuration containing table properties * @throws TableNotFoundException * if the table is not found * @throws AccumuloException * if there is a problem communicating to Accumulo */ public static AccumuloConfiguration getTableConfiguration(Connector conn, String tableId) throws TableNotFoundException, AccumuloException { String tableName = Tables.getTableName(conn.getInstance(), tableId); return new ConfigurationCopy(conn.tableOperations().getProperties(tableName)); }
@Test public void createTable() throws TableExistsException, AccumuloException, AccumuloSecurityException, TableNotFoundException { String tableName = getUniqueNames(1)[0]; connector.tableOperations().create(tableName); Iterable<Map.Entry<String,String>> itrProps = connector.tableOperations() .getProperties(tableName); Map<String,String> props = propsToMap(itrProps); assertEquals(DefaultKeySizeConstraint.class.getName(), props.get(Property.TABLE_CONSTRAINT_PREFIX.toString() + "1")); connector.tableOperations().delete(tableName); }
@Test(timeout = 4 * 60 * 1000) public void testMetaDurability() throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.instanceOperations().setProperty(Property.TABLE_DURABILITY.getKey(), "none"); Map<String,String> props = map(c.tableOperations().getProperties(MetadataTable.NAME)); assertEquals("sync", props.get(Property.TABLE_DURABILITY.getKey())); c.tableOperations().create(tableName); props = map(c.tableOperations().getProperties(tableName)); assertEquals("none", props.get(Property.TABLE_DURABILITY.getKey())); restartTServer(); assertTrue(c.tableOperations().exists(tableName)); }
public void start(String[] args) throws MergeException { Opts opts = new Opts(); opts.parseArgs(Merge.class.getName(), args); try { Connector conn = opts.getConnector(); if (!conn.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( conn.tableOperations().getProperties(opts.getTableName())); opts.goalSize = tableConfig.getMemoryInBytes(Property.TABLE_SPLIT_THRESHOLD); } message("Merging tablets in table %s to %d bytes", opts.getTableName(), opts.goalSize); mergomatic(conn, opts.getTableName(), opts.begin, opts.end, opts.goalSize, opts.force); } catch (Exception ex) { throw new MergeException(ex); } }