use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project accumulo by apache.
the class ZooLockTest method setupMiniCluster.
@BeforeClass
public static void setupMiniCluster() throws Exception {
folder.create();
accumulo = new MiniAccumuloCluster(folder.getRoot(), "superSecret");
accumulo.start();
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project presto by prestodb.
the class AccumuloQueryRunner method getAccumuloConnector.
/**
* 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);
}
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project presto by prestodb.
the class AccumuloQueryRunner method createMiniAccumuloCluster.
/**
* Creates and starts an instance of MiniAccumuloCluster, returning the new instance.
*
* @return New MiniAccumuloCluster
*/
private static MiniAccumuloCluster createMiniAccumuloCluster() throws IOException, InterruptedException {
// Create MAC directory
File macDir = Files.createTempDirectory("mac-").toFile();
LOG.info("MAC is enabled, starting MiniAccumuloCluster at %s", macDir);
// Start MAC and connect to it
MiniAccumuloCluster accumulo = new MiniAccumuloCluster(macDir, MAC_PASSWORD);
accumulo.getConfig().setDefaultMemory(512, MEGABYTE);
setConfigClassPath(accumulo.getConfig());
accumulo.start();
// Add shutdown hook to stop MAC and cleanup temporary files
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
LOG.info("Shutting down MAC");
accumulo.stop();
} catch (IOException | InterruptedException e) {
Thread.currentThread().interrupt();
throw new PrestoException(MINI_ACCUMULO, "Failed to shut down MAC instance", e);
}
try {
LOG.info("Cleaning up MAC directory");
FileUtils.forceDelete(macDir);
} catch (IOException e) {
throw new PrestoException(MINI_ACCUMULO, "Failed to clean up MAC directory", e);
}
}));
return accumulo;
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class RFileReaderRddIT method throwRTX_whenGetPartitionsForFileReaderWithInvalidTableName.
public void throwRTX_whenGetPartitionsForFileReaderWithInvalidTableName() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
// Given
final MiniAccumuloCluster cluster = createAccumuloCluster(tableName, config, Arrays.asList("Bananas"));
final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(), cluster.getInstanceName(), cluster.getZooKeepers(), MiniAccumuloClusterProvider.USER, MiniAccumuloClusterProvider.PASSWORD, "Invalid Table Name", new HashSet<>(), serialiseConfiguration(config));
// When / Then
assertThatExceptionOfType(RuntimeException.class).isThrownBy(rdd::getPartitions).withMessage("User user does not have access to table Invalid Table Name");
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class RFileReaderRddIT method throwRTX_whenRDDHasIncorrectUser.
@Test
public void throwRTX_whenRDDHasIncorrectUser() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
// Given
final MiniAccumuloCluster cluster = createAccumuloCluster(tableName, config, Arrays.asList("Bananas"));
final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(), cluster.getInstanceName(), cluster.getZooKeepers(), "Incorrect Username", "", tableName, new HashSet<>(), serialiseConfiguration(config));
// When / Then
assertThatExceptionOfType(RuntimeException.class).isThrownBy(rdd::getPartitions).withMessage("Exception connecting to Accumulo");
}
Aggregations