@Override public Connector get() { try { Instance inst = new ZooKeeperInstance(instance, zooKeepers); Connector connector = inst.getConnector(username, new PasswordToken(password.getBytes(UTF_8))); LOG.info("Connection to instance %s at %s established, user %s", instance, zooKeepers, username); return connector; } catch (AccumuloException | AccumuloSecurityException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } } }
@Override public CredentialProviderToken clone() { CredentialProviderToken clone = (CredentialProviderToken) super.clone(); clone.setPassword(this.getPassword()); return clone; }
@Override public void init(Properties properties) { if (properties.containsKey("password")) { setPassword(CharBuffer.wrap(properties.get("password"))); } else throw new IllegalArgumentException("Missing 'password' property"); }
@Override public boolean containsValue(Object value) { checkDestroyed(); char[] v = (char[]) value; return map.containsValue(v); }
@Override public Set<TokenProperty> getProperties() { LinkedHashSet<TokenProperty> properties = new LinkedHashSet<>(); // Neither name or CPs are sensitive properties .add(new TokenProperty(NAME_PROPERTY, "Alias to extract from CredentialProvider", false)); properties.add(new TokenProperty(CREDENTIAL_PROVIDERS_PROPERTY, "Comma separated list of URLs defining CredentialProvider(s)", false)); return properties; }
public CredentialProviderToken(String name, String credentialProviders) throws IOException { requireNonNull(name); requireNonNull(credentialProviders); setWithCredentialProviders(name, credentialProviders); }
@Override public void write(DataOutput out) throws IOException { super.write(out); identifier.write(out); }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance( getProperties().getProperty("accumulo.instanceName"), getProperties().getProperty("accumulo.zooKeepers")); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public char[] get(Object key) { checkDestroyed(); String k = (String) key; return map.get(k); }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public char[] remove(Object key) { checkDestroyed(); String k = (String) key; return map.remove(k); }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public Set<String> keySet() { checkDestroyed(); return map.keySet(); }
/** * Gets the AccumuloConnector singleton, starting the MiniAccumuloCluster on initialization. * This singleton instance is required so all test cases access the same MiniAccumuloCluster. * * @return Accumulo connector */ public static Connector getAccumuloConnector() { if (connector != null) { return connector; } try { MiniAccumuloCluster accumulo = createMiniAccumuloCluster(); Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers()); connector = instance.getConnector(MAC_USER, new PasswordToken(MAC_PASSWORD)); LOG.info("Connection to MAC instance %s at %s established, user %s password %s", accumulo.getInstanceName(), accumulo.getZooKeepers(), MAC_USER, MAC_PASSWORD); return connector; } catch (AccumuloException | AccumuloSecurityException | InterruptedException | IOException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } }
@Override public Collection<char[]> values() { checkDestroyed(); return map.values(); }
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
@Override public Set<Map.Entry<String,char[]>> entrySet() { checkDestroyed(); return map.entrySet(); } }
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
@Override public void clear() { checkDestroyed(); map.clear(); }