org.apache.accumulo.core.client.Instance.getConnector()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.apache.accumulo.core.client.Instance.getConnector()方法的一些代码示例,展示了Instance.getConnector()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getConnector()方法的具体详情如下:
包路径:org.apache.accumulo.core.client.Instance
类名称:Instance
方法名:getConnector

Instance.getConnector介绍

[英]Returns a connection to this instance of accumulo.
[中]返回与此accumulo实例的连接。

代码示例

代码示例来源:origin: prestodb/presto

@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);
    }
  }
}

代码示例来源:origin: prestodb/presto

Connector conn = inst.getConnector("root", new PasswordToken(""));
conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());

代码示例来源:origin: prestodb/presto

Connector conn = inst.getConnector("root", new PasswordToken(""));
conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());

代码示例来源:origin: prestodb/presto

/**
 * 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);
  }
}

代码示例来源:origin: apache/accumulo

/**
 * 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));
}

代码示例来源:origin: apache/accumulo

/**
 * 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));
}

代码示例来源:origin: apache/accumulo

/**
 * 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));
}

代码示例来源:origin: apache/accumulo

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();
}

代码示例来源:origin: apache/accumulo

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);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-minicluster

@Override
public Connector getConnector(String user, AuthenticationToken token)
  throws AccumuloException, AccumuloSecurityException {
 return instance.getConnector(user, token);
}

代码示例来源:origin: NationalSecurityAgency/datawave

/**
 * @return Connector to Accumulo given this objects settings.
 * @throws AccumuloSecurityException
 * @throws AccumuloException
 */
public Connector getConnector() throws AccumuloSecurityException, AccumuloException {
  return getInstance().getConnector(username, password);
}

代码示例来源:origin: com.boozallen.cognition/spark-accumulo

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;
}

代码示例来源:origin: org.apache.accumulo/accumulo-minicluster

@Override
public Connector getConnector(String user, AuthenticationToken token)
  throws AccumuloException, AccumuloSecurityException {
 Instance instance = new ZooKeeperInstance(getClientConfig());
 return instance.getConnector(user, token);
}

代码示例来源:origin: org.apache.accumulo/accumulo-server

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;
}

代码示例来源:origin: org.apache.accumulo/accumulo-proxy

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);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

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);
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

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);
}

代码示例来源:origin: apache/incubator-rya

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()));
}

代码示例来源:origin: apache/incubator-rya

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);
}

代码示例来源:origin: lumifyio/lumify

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);
}

相关文章