use of org.apache.accumulo.core.client.TableNotFoundException in project incubator-rya by apache.
the class AccumuloTemporalIndexer method getScanner.
/**
* creates a scanner and handles all the throwables and nulls.
*
* @param scanner
* @return
* @throws IOException
*/
private Scanner getScanner() throws QueryEvaluationException {
final String whileDoing = "While creating a scanner for a temporal query. table name=" + temporalIndexTableName;
Scanner scanner = null;
try {
scanner = ConfigUtils.createScanner(temporalIndexTableName, conf);
} catch (final AccumuloException e) {
logger.error(whileDoing, e);
throw new QueryEvaluationException(whileDoing, e);
} catch (final AccumuloSecurityException e) {
throw new QueryEvaluationException(whileDoing, e);
} catch (final TableNotFoundException e) {
logger.error(whileDoing, e);
throw new QueryEvaluationException(whileDoing + " The temporal index table should have been created by this constructor, if found missing.", e);
}
return scanner;
}
use of org.apache.accumulo.core.client.TableNotFoundException in project incubator-rya by apache.
the class AccumuloRyaUtils method getScanner.
/**
* Creates a {@link Scanner} of the provided table name using the specified {@link Configuration}.
* @param tablename the name of the table to scan.
* @param config the {@link Configuration}.
* @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner.
* {@code false} otherwise.
* @return the {@link Scanner} for the table.
* @throws IOException
*/
public static Scanner getScanner(final String tableName, final Configuration config, final boolean shouldAddCommonIterators) throws IOException {
try {
final String instanceName = config.get(ConfigUtils.CLOUDBASE_INSTANCE);
final String zooKeepers = config.get(ConfigUtils.CLOUDBASE_ZOOKEEPERS);
Instance instance;
if (ConfigUtils.useMockInstance(config)) {
instance = new MockInstance(config.get(ConfigUtils.CLOUDBASE_INSTANCE));
} else {
instance = new ZooKeeperInstance(new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers));
}
final String username = ConfigUtils.getUsername(config);
final String password = ConfigUtils.getPassword(config);
final Connector connector = instance.getConnector(username, new PasswordToken(password));
final Authorizations auths = ConfigUtils.getAuthorizations(config);
final Scanner scanner = connector.createScanner(tableName, auths);
if (shouldAddCommonIterators) {
AccumuloRyaUtils.addCommonScannerIteratorsTo(scanner);
}
return scanner;
} catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
log.error("Error connecting to " + tableName);
throw new IOException(e);
}
}
use of org.apache.accumulo.core.client.TableNotFoundException in project incubator-rya by apache.
the class AccumuloIndexSet method setLocalityGroups.
/**
* @param tableName
* @param conn
* @param groups
* - locality groups to be created
*
* Sets locality groups for more efficient scans - these are
* usually the variable orders in the table so that scans for
* specific orders are more efficient
*/
private void setLocalityGroups(final String tableName, final Connector conn, final List<String> groups) {
final HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>();
for (int i = 0; i < groups.size(); i++) {
final HashSet<Text> tempColumn = new HashSet<Text>();
tempColumn.add(new Text(groups.get(i)));
final String groupName = groups.get(i).replace(VALUE_DELIM, "");
localityGroups.put(groupName, tempColumn);
}
try {
conn.tableOperations().setLocalityGroups(tableName, localityGroups);
} catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
e.printStackTrace();
}
}
use of org.apache.accumulo.core.client.TableNotFoundException in project incubator-rya by apache.
the class PcjIntegrationTestingUtil method writeResults.
/**
* Add a collection of results to a specific PCJ table.
*
* @param accumuloConn
* - A connection to the Accumulo that hosts the PCJ table. (not
* null)
* @param pcjTableName
* - The name of the PCJ table that will receive the results.
* (not null)
* @param results
* - Binding sets that will be written to the PCJ table. (not
* null)
* @throws PcjException
* The provided PCJ table doesn't exist, is missing the PCJ
* metadata, or the result could not be written to it.
*/
private static void writeResults(final Connector accumuloConn, final String pcjTableName, final Collection<BindingSet> results) throws PcjException {
checkNotNull(accumuloConn);
checkNotNull(pcjTableName);
checkNotNull(results);
// Fetch the variable orders from the PCJ table.
final PcjMetadata metadata = new PcjTables().getPcjMetadata(accumuloConn, pcjTableName);
// Write each result formatted using each of the variable orders.
BatchWriter writer = null;
try {
writer = accumuloConn.createBatchWriter(pcjTableName, new BatchWriterConfig());
for (final BindingSet result : results) {
final Set<Mutation> addResultMutations = makeWriteResultMutations(metadata.getVarOrders(), result);
writer.addMutations(addResultMutations);
}
} catch (TableNotFoundException | MutationsRejectedException e) {
throw new PcjException("Could not add results to the PCJ table named: " + pcjTableName, e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (final MutationsRejectedException e) {
throw new PcjException("Could not add results to a PCJ table because some of the mutations were rejected.", e);
}
}
}
}
use of org.apache.accumulo.core.client.TableNotFoundException in project incubator-rya by apache.
the class PcjTables method dropPcjTable.
/**
* Drops a PCJ index from Accumulo.
*
* @param accumuloConn - Connects to the Accumulo that hosts the PCJ indices. (not null)
* @param pcjTableName - The name of the PCJ table that will be dropped. (not null)
* @throws PCJStorageException - The table could not be dropped because of
* a security exception or because it does not exist.
*/
public void dropPcjTable(final Connector accumuloConn, final String pcjTableName) throws PCJStorageException {
checkNotNull(accumuloConn);
checkNotNull(pcjTableName);
try {
accumuloConn.tableOperations().delete(pcjTableName);
} catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
throw new PCJStorageException("Could not delete PCJ table named: " + pcjTableName, e);
}
}
Aggregations