@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); } } }
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
/** * 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); } }
/** * Returns a connection to accumulo. * * @param user * a valid accumulo user * @param pass * A UTF-8 encoded password. The password may be cleared after making this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
/** * Returns a connection to accumulo. * * @param user * a valid accumulo user * @param pass * A UTF-8 encoded password. The password may be cleared after making this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
/** * Returns a connection to this instance of accumulo. * * @param user * a valid accumulo user * @param pass * If a mutable CharSequence is passed in, it may be cleared after this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
public static ClientContext client(Class<?> CLASS, Configuration conf) throws AccumuloException, AccumuloSecurityException { return ((org.apache.accumulo.core.clientImpl.ConnectorImpl) getInstance(CLASS, conf) .getConnector(getPrincipal(CLASS, conf), getAuthenticationToken(CLASS, conf))) .getAccumuloClient(); }
public static ClientContext client(Class<?> CLASS, org.apache.accumulo.core.client.mapreduce.RangeInputSplit split, Configuration conf) throws IOException { try { org.apache.accumulo.core.client.Instance instance = split .getInstance(getClientConfiguration(CLASS, conf)); if (instance == null) { instance = getInstance(CLASS, conf); } String principal = split.getPrincipal(); if (principal == null) { principal = getPrincipal(CLASS, conf); } AuthenticationToken token = split.getToken(); if (token == null) { token = getAuthenticationToken(CLASS, conf); } return ((org.apache.accumulo.core.clientImpl.ConnectorImpl) instance.getConnector(principal, token)).getAccumuloClient(); } catch (AccumuloException | AccumuloSecurityException e) { throw new IOException(e); } }
@Override public Connector getConnector(String user, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException { return instance.getConnector(user, token); }
/** * @return Connector to Accumulo given this objects settings. * @throws AccumuloSecurityException * @throws AccumuloException */ public Connector getConnector() throws AccumuloSecurityException, AccumuloException { return getInstance().getConnector(username, password); }
public Connector getConnector(){ //lazy initialize try { conn = zkInstance.getConnector(accumuloUser, new PasswordToken(accumuloPassword)); } catch (AccumuloException | AccumuloSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
@Override public Connector getConnector(String user, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException { Instance instance = new ZooKeeperInstance(getClientConfig()); return instance.getConnector(user, token); }
protected TableOperations getTableOperations() { if (tops == null) try { tops = configuration.getInstance().getConnector(SecurityConstants.getSystemPrincipal(), SecurityConstants.getSystemToken()).tableOperations(); } catch (AccumuloException e) { log.error("Unable to access table operations from within table balancer", e); } catch (AccumuloSecurityException e) { log.error("Unable to access table operations from within table balancer", e); } return tops; }
protected Connector getConnector(ByteBuffer login) throws Exception { String[] pair = ByteBufferUtil.toString(login).split(",", 2); if (instance.getInstanceID().equals(pair[0])) { Credentials creds = Credentials.deserialize(pair[1]); return instance.getConnector(creds.getPrincipal(), creds.getToken()); } else { throw new org.apache.accumulo.core.client.AccumuloSecurityException(pair[0], org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode.INVALID_INSTANCEID); } }
Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobContext context, String tableId, List<Range> ranges) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { Instance instance = getInstance(context); Connector conn = instance.getConnector(getPrincipal(context), getAuthenticationToken(context)); return InputConfigurator.binOffline(tableId, ranges, instance, conn); }
Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobConf job, String tableId, List<Range> ranges) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { Instance instance = getInstance(job); Connector conn = instance.getConnector(getPrincipal(job), getAuthenticationToken(job)); return InputConfigurator.binOffline(tableId, ranges, instance, conn); }
private static Connector createAccumuloConnector(final PcjAdminClientProperties clientProps) throws AccumuloException, AccumuloSecurityException { checkNotNull(clientProps); // Connect to the Zookeepers. final String instanceName = clientProps.getAccumuloInstance(); final String zooServers = clientProps.getAccumuloZookeepers(); final Instance inst = new ZooKeeperInstance(instanceName, zooServers); // Create a connector to the Accumulo that hosts the PCJ export tables. return inst.getConnector(clientProps.getAccumuloUsername(), new PasswordToken(clientProps.getAccumuloPassword())); }
private static PeriodicQueryResultStorage getPeriodicQueryResultStorage(final PeriodicNotificationApplicationConfiguration conf) throws AccumuloException, AccumuloSecurityException { final Instance instance = new ZooKeeperInstance(conf.getAccumuloInstance(), conf.getAccumuloZookeepers()); final Connector conn = instance.getConnector(conf.getAccumuloUser(), new PasswordToken(conf.getAccumuloPassword())); final String ryaInstance = conf.getTablePrefix(); return new AccumuloPeriodicQueryResultStorage(conn, ryaInstance); }
protected Connector createAccumuloConnection(BackupRestoreOptionsBase options) throws AccumuloSecurityException, AccumuloException { String instanceName = options.getAccumuloInstanceName(); String zooServers = options.getZookeeperServers(); Instance inst = new ZooKeeperInstance(instanceName, zooServers); ConfigurationCopy conf = new ConfigurationCopy(inst.getConfiguration()); conf.set(Property.INSTANCE_DFS_URI, options.getHadoopFsDefaultFS()); inst.setConfiguration(conf); AuthenticationToken authenticationToken = new PasswordToken(options.getAccumuloPassword()); return inst.getConnector(options.getAccumuloUserName(), authenticationToken); }