Tabnine Logo
org.apache.accumulo.core.client.admin
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.accumulo.core.client.admin

Best Java code snippets using org.apache.accumulo.core.client.admin (Showing top 20 results out of 558)

origin: prestodb/presto

public boolean exists(String table)
{
  return connector.tableOperations().exists(table);
}
origin: prestodb/presto

@Inject
public AccumuloClient(
    Connector connector,
    AccumuloConfig config,
    ZooKeeperMetadataManager metaManager,
    AccumuloTableManager tableManager,
    IndexLookup indexLookup)
    throws AccumuloException, AccumuloSecurityException
{
  this.connector = requireNonNull(connector, "connector is null");
  this.username = requireNonNull(config, "config is null").getUsername();
  this.metaManager = requireNonNull(metaManager, "metaManager is null");
  this.tableManager = requireNonNull(tableManager, "tableManager is null");
  this.indexLookup = requireNonNull(indexLookup, "indexLookup is null");
  this.auths = connector.securityOperations().getUserAuthorizations(username);
}
origin: prestodb/presto

public void createAccumuloTable(String table)
{
  try {
    connector.tableOperations().create(table);
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to create Accumulo table", e);
  }
  catch (TableExistsException e) {
    throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Accumulo table already exists", e);
  }
}
origin: prestodb/presto

conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());
conn.tableOperations().create(table.getMetricsTableName());
  conn.tableOperations().attachIterator(table.getMetricsTableName(), s);
origin: prestodb/presto

public void setIterator(String table, IteratorSetting setting)
{
  try {
    // Remove any existing iterator settings of the same name, if applicable
    Map<String, EnumSet<IteratorScope>> iterators = connector.tableOperations().listIterators(table);
    if (iterators.containsKey(setting.getName())) {
      connector.tableOperations().removeIterator(table, setting.getName(), iterators.get(setting.getName()));
    }
    connector.tableOperations().attachIterator(table, setting);
  }
  catch (AccumuloSecurityException | AccumuloException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to set iterator on table " + table, e);
  }
  catch (TableNotFoundException e) {
    throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to set iterator, table does not exist", e);
  }
}
origin: prestodb/presto

private Optional<String> getDefaultTabletLocation(String fulltable)
{
  try {
    String tableId = connector.tableOperations().tableIdMap().get(fulltable);
    // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row
    Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username));
    scan.fetchColumnFamily(new Text("loc"));
    scan.setRange(new Range(tableId + '<'));
    // scan the entry
    Optional<String> location = Optional.empty();
    for (Entry<Key, Value> entry : scan) {
      if (location.isPresent()) {
        throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry");
      }
      location = Optional.of(entry.getValue().toString());
    }
    scan.close();
    return location;
  }
  catch (Exception e) {
    // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet.
    // This is purely an optimization, but we will want to log the error.
    LOG.error("Failed to get tablet location, returning dummy location", e);
    return Optional.empty();
  }
}
origin: prestodb/presto

public void deleteAccumuloTable(String tableName)
{
  try {
    connector.tableOperations().delete(tableName);
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to delete Accumulo table", e);
  }
  catch (TableNotFoundException e) {
    throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to delete Accumulo table, does not exist", e);
  }
}
origin: prestodb/presto

/**
 * Ensures the given Accumulo namespace exist, creating it if necessary
 *
 * @param schema Presto schema (Accumulo namespace)
 */
public void ensureNamespace(String schema)
{
  try {
    // If the table schema is not "default" and the namespace does not exist, create it
    if (!schema.equals(DEFAULT) && !connector.namespaceOperations().exists(schema)) {
      connector.namespaceOperations().create(schema);
    }
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to check for existence or create Accumulo namespace", e);
  }
  catch (NamespaceExistsException e) {
    // Suppress race condition between test for existence and creation
    LOG.warn("NamespaceExistsException suppressed when creating " + schema);
  }
}
origin: prestodb/presto

public static synchronized DistributedQueryRunner createAccumuloQueryRunner(Map<String, String> extraProperties)
    throws Exception
{
  DistributedQueryRunner queryRunner =
      new DistributedQueryRunner(createSession(), 4, extraProperties);
  queryRunner.installPlugin(new TpchPlugin());
  queryRunner.createCatalog("tpch", "tpch");
  queryRunner.installPlugin(new AccumuloPlugin());
  Map<String, String> accumuloProperties =
      ImmutableMap.<String, String>builder()
          .put(AccumuloConfig.INSTANCE, connector.getInstance().getInstanceName())
          .put(AccumuloConfig.ZOOKEEPERS, connector.getInstance().getZooKeepers())
          .put(AccumuloConfig.USERNAME, MAC_USER)
          .put(AccumuloConfig.PASSWORD, MAC_PASSWORD)
          .put(AccumuloConfig.ZOOKEEPER_METADATA_ROOT, "/presto-accumulo-test")
          .build();
  queryRunner.createCatalog("accumulo", "accumulo", accumuloProperties);
  if (!tpchLoaded) {
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), TpchTable.getTables());
    connector.tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L))));
    tpchLoaded = true;
  }
  return queryRunner;
}
origin: prestodb/presto

String tableId = connector.tableOperations().tableIdMap().get(table);
origin: prestodb/presto

public void setLocalityGroups(String tableName, Map<String, Set<Text>> groups)
{
  if (groups.isEmpty()) {
    return;
  }
  try {
    connector.tableOperations().setLocalityGroups(tableName, groups);
    LOG.debug("Set locality groups for %s to %s", tableName, groups);
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to set locality groups", e);
  }
  catch (TableNotFoundException e) {
    throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to set locality groups, table does not exist", e);
  }
}
origin: prestodb/presto

  public void renameAccumuloTable(String oldName, String newName)
  {
    try {
      connector.tableOperations().rename(oldName, newName);
    }
    catch (AccumuloSecurityException | AccumuloException e) {
      throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to rename table", e);
    }
    catch (TableNotFoundException e) {
      throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to rename table, old table does not exist", e);
    }
    catch (TableExistsException e) {
      throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Failed to rename table, new table already exists", e);
    }
  }
}
origin: prestodb/presto

private Collection<Range> splitByTabletBoundaries(String tableName, Collection<Range> ranges)
    throws org.apache.accumulo.core.client.TableNotFoundException, AccumuloException, AccumuloSecurityException
{
  ImmutableSet.Builder<Range> rangeBuilder = ImmutableSet.builder();
  for (Range range : ranges) {
    // if start and end key are equivalent, no need to split the range
    if (range.getStartKey() != null && range.getEndKey() != null && range.getStartKey().equals(range.getEndKey())) {
      rangeBuilder.add(range);
    }
    else {
      // Call out to Accumulo to split the range on tablets
      rangeBuilder.addAll(connector.tableOperations().splitRangeByTablets(tableName, range, Integer.MAX_VALUE));
    }
  }
  return rangeBuilder.build();
}
origin: apache/accumulo

/**
 * Serialize the delegation token config into the thrift variant
 *
 * @param config
 *          The configuration
 */
public static TDelegationTokenConfig serialize(DelegationTokenConfig config) {
 TDelegationTokenConfig tconfig = new TDelegationTokenConfig();
 tconfig.setLifetime(config.getTokenLifetime(TimeUnit.MILLISECONDS));
 return tconfig;
}
origin: prestodb/presto

conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());
conn.tableOperations().create(table.getMetricsTableName());
  conn.tableOperations().attachIterator(table.getMetricsTableName(), s);
origin: prestodb/presto

Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
LOG.debug("Using session scanner auths for user %s: %s", sessionScanUser, scanAuths);
return scanAuths;
Authorizations auths = connector.securityOperations().getUserAuthorizations(username);
LOG.debug("scan_auths table property not set, using user auths: %s", auths);
return auths;
origin: prestodb/presto

/**
 * Loads the cardinality for the given Range. Uses a BatchScanner and sums the cardinality for all values that encapsulate the Range.
 *
 * @param key Range to get the cardinality for
 * @return The cardinality of the column, which would be zero if the value does not exist
 */
@Override
public Long load(CacheKey key)
    throws Exception
{
  LOG.debug("Loading a non-exact range from Accumulo: %s", key);
  // Get metrics table name and the column family for the scanner
  String metricsTable = getMetricsTableName(key.getSchema(), key.getTable());
  Text columnFamily = new Text(getIndexColumnFamily(key.getFamily().getBytes(UTF_8), key.getQualifier().getBytes(UTF_8)).array());
  // Create scanner for querying the range
  BatchScanner scanner = connector.createBatchScanner(metricsTable, key.auths, 10);
  scanner.setRanges(connector.tableOperations().splitRangeByTablets(metricsTable, key.range, Integer.MAX_VALUE));
  scanner.fetchColumn(columnFamily, CARDINALITY_CQ_AS_TEXT);
  try {
    return stream(scanner)
        .map(Entry::getValue)
        .map(Value::toString)
        .mapToLong(Long::parseLong)
        .sum();
  }
  finally {
    scanner.close();
  }
}
origin: prestodb/presto

new Indexer(
    connector,
    connector.securityOperations().getUserAuthorizations(username),
    table,
    conf));
origin: prestodb/presto

Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
LOG.debug("Using session scan auths for user %s: %s", sessionScanUser, scanAuths);
return scanAuths;
origin: apache/accumulo

@Override
public BatchScanner createBatchScanner(String tableName)
  throws TableNotFoundException, AccumuloSecurityException, AccumuloException {
 Authorizations auths = securityOperations().getUserAuthorizations(getPrincipal());
 return createBatchScanner(tableName, auths);
}
org.apache.accumulo.core.client.admin

Most used classes

  • TableOperations
    Provides a class for administering tables
  • SecurityOperations
  • InstanceOperations
  • NamespaceOperations
    Provides an API for administering namespaces All tables exist in a namespace. The default namespace
  • NewTableConfiguration
    This object stores table creation parameters. Currently includes: TimeType, whether to include defau
  • DelegationTokenConfig,
  • DiskUsage,
  • TimeType,
  • CompactionConfig,
  • ActiveScan,
  • ActiveCompaction$CompactionReason,
  • ActiveCompaction$CompactionType,
  • ActiveCompaction,
  • InitialTableState,
  • ScanState,
  • ScanType,
  • FindMax,
  • Locations,
  • ReplicationOperations
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now