Search in sources :

Example 1 with InMemoryTabletLocator

use of datawave.accumulo.inmemory.impl.InMemoryTabletLocator in project datawave by NationalSecurityAgency.

the class PushdownScheduler method concatIterators.

/**
 * @return
 * @throws ParseException
 * @throws TableNotFoundException
 * @throws AccumuloSecurityException
 * @throws AccumuloException
 */
protected Iterator<Entry<Key, Value>> concatIterators() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, ParseException {
    String tableName = config.getShardTableName();
    Set<Authorizations> auths = config.getAuthorizations();
    TabletLocator tl;
    Instance instance = config.getConnector().getInstance();
    if (instance instanceof InMemoryInstance) {
        tl = new InMemoryTabletLocator();
        tableId = config.getTableName();
    } else {
        tableId = Tables.getTableId(instance, tableName);
        Credentials credentials = new Credentials(config.getConnector().whoami(), new PasswordToken(config.getAccumuloPassword()));
        tl = TabletLocator.getLocator(new ClientContext(instance, credentials, AccumuloConfiguration.getDefaultConfiguration()), tableId);
    }
    Iterator<List<ScannerChunk>> chunkIter = Iterators.transform(getQueryDataIterator(), new PushdownFunction(tl, config, settings, tableId));
    try {
        session = scannerFactory.newQueryScanner(tableName, auths, config.getQuery());
        if (config.getBypassAccumulo()) {
            session.setDelegatedInitializer(RfileResource.class);
        }
        if (config.getSpeculativeScanning()) {
            session.setSpeculativeScanning(true);
        }
        session.addVisitor(new VisitorFunction(config, metadataHelper));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    session.setScanLimit(config.getMaxDocScanTimeout());
    if (config.getBackoffEnabled()) {
        session.setBackoffEnabled(true);
    }
    session.setChunkIter(chunkIter);
    session.setTabletLocator(tl);
    session.updateIdentifier(config.getQuery().getId().toString());
    return session;
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) VisitorFunction(datawave.query.tables.async.event.VisitorFunction) Instance(org.apache.accumulo.core.client.Instance) InMemoryInstance(datawave.accumulo.inmemory.InMemoryInstance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) InMemoryInstance(datawave.accumulo.inmemory.InMemoryInstance) ParseException(org.apache.commons.jexl2.parser.ParseException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) InMemoryTabletLocator(datawave.accumulo.inmemory.impl.InMemoryTabletLocator) TabletLocator(org.apache.accumulo.core.client.impl.TabletLocator) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) List(java.util.List) InMemoryTabletLocator(datawave.accumulo.inmemory.impl.InMemoryTabletLocator) Credentials(org.apache.accumulo.core.client.impl.Credentials)

Example 2 with InMemoryTabletLocator

use of datawave.accumulo.inmemory.impl.InMemoryTabletLocator in project datawave by NationalSecurityAgency.

the class BulkInputFormat method getTabletLocator.

/**
 * Initializes an Accumulo {@link TabletLocator} based on the configuration.
 *
 * @param conf
 *            the Hadoop configuration object
 * @return an accumulo tablet locator
 * @throws TableNotFoundException
 *             if the table name set on the configuration doesn't exist
 * @throws IOException
 *             if the input format is unable to read the password file from the FileSystem
 */
protected static TabletLocator getTabletLocator(Configuration conf) throws TableNotFoundException, IOException {
    if (conf.getBoolean(MOCK, false))
        return new InMemoryTabletLocator();
    Instance instance = getInstance(conf);
    String tableName = getTablename(conf);
    Credentials credentials = new Credentials(getUsername(conf), new PasswordToken(getPassword(conf)));
    return TabletLocator.getLocator(new ClientContext(instance, credentials, AccumuloConfiguration.getDefaultConfiguration()), Tables.getTableId(instance, tableName));
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) InMemoryInstance(datawave.accumulo.inmemory.InMemoryInstance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) InMemoryTabletLocator(datawave.accumulo.inmemory.impl.InMemoryTabletLocator) Credentials(org.apache.accumulo.core.client.impl.Credentials)

Aggregations

InMemoryInstance (datawave.accumulo.inmemory.InMemoryInstance)2 InMemoryTabletLocator (datawave.accumulo.inmemory.impl.InMemoryTabletLocator)2 Instance (org.apache.accumulo.core.client.Instance)2 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)2 Credentials (org.apache.accumulo.core.client.impl.Credentials)2 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)2 VisitorFunction (datawave.query.tables.async.event.VisitorFunction)1 IOException (java.io.IOException)1 List (java.util.List)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)1 TabletLocator (org.apache.accumulo.core.client.impl.TabletLocator)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 ParseException (org.apache.commons.jexl2.parser.ParseException)1