use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class RFileReaderRddIT method testRFileReaderRDDCanBeCreatedWith5TableInputs.
@Test
public void testRFileReaderRDDCanBeCreatedWith5TableInputs() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
// Given
final List<String> dataInput = Arrays.asList("train", "plane", "automobile", "bike", "boat");
final MiniAccumuloCluster cluster = createAccumuloCluster(tableName, config, dataInput);
// When
final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(), cluster.getInstanceName(), cluster.getZooKeepers(), MiniAccumuloClusterProvider.USER, MiniAccumuloClusterProvider.PASSWORD, tableName, new HashSet<>(), serialiseConfiguration(config));
// Then
assertThat(rdd.count()).isEqualTo(dataInput.size());
assertThat(rdd.getPartitions()).hasSize(1);
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class MiniAccumuloClusterProvider method createCluster.
private static void createCluster() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException {
if (tempFolder.exists()) {
FileUtils.cleanDirectory(tempFolder);
}
final MiniAccumuloConfig miniAccumuloConfig = new MiniAccumuloConfig(tempFolder, PASSWORD);
cluster = new MiniAccumuloCluster(miniAccumuloConfig);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
cluster.stop();
tempFolder.delete();
} catch (final IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
});
cluster.start();
// Create user USER with permissions to create a table
cluster.getConnector(ROOT, PASSWORD).securityOperations().createLocalUser(USER, new PasswordToken(PASSWORD));
cluster.getConnector(ROOT, PASSWORD).securityOperations().createLocalUser(USER_NO_GRANTED_PERMISSION, new PasswordToken(PASSWORD));
cluster.getConnector(ROOT, PASSWORD).securityOperations().grantSystemPermission(USER, SystemPermission.CREATE_TABLE);
// Create properties
accumuloProperties = new AccumuloProperties();
accumuloProperties.setStoreClass(AccumuloStore.class);
accumuloProperties.setInstance(cluster.getInstanceName());
accumuloProperties.setZookeepers(cluster.getZooKeepers());
accumuloProperties.setUser(MiniAccumuloClusterProvider.USER);
accumuloProperties.setPassword(MiniAccumuloClusterProvider.PASSWORD);
accumuloProperties.setOperationDeclarationPaths("sparkAccumuloOperationsDeclarations.json");
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class MiniAccumuloStore method createCluster.
private void createCluster() throws IOException, InterruptedException {
String providedDirectory = getProperties().get(ACCUMULO_DIRECTORY_PROPERTY);
if (providedDirectory == null) {
ACCUMULO_DIRECTORIES.put(getProperties().getInstance(), Files.createTempDir());
} else {
ACCUMULO_DIRECTORIES.put(getProperties().getInstance(), new File(providedDirectory));
}
String rootUserPassword = getProperties().get(ROOT_PASSWORD_PROPERTY, ROOT_PASSWORD_DEFAULT);
MiniAccumuloConfig config = new MiniAccumuloConfig(getAccumuloDirectory(), rootUserPassword);
String[] zookeepers = getProperties().getZookeepers().split(":");
if (zookeepers.length == 2) {
config.setZooKeeperPort(Integer.parseInt(zookeepers[1]));
} else {
config.setZooKeeperPort(DEFAULT_ZOOKEEPER_PORT);
}
config.setInstanceName(getProperties().getInstance());
CLUSTER_INSTANCES.put(getProperties().getInstance(), new MiniAccumuloCluster(config));
getCluster().start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
if (this.getCluster() != null) {
this.getCluster().stop();
}
} catch (final InterruptedException | IOException e) {
LOGGER.error("Failed to stop Accumulo", e);
}
getAccumuloDirectory().delete();
}));
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project vertexium by visallo.
the class AccumuloResource method start.
public void start() throws IOException, InterruptedException {
if (accumulo != null) {
return;
}
LOGGER.info("Starting accumulo");
tempDir = File.createTempFile("accumulo-temp", Long.toString(System.nanoTime()));
tempDir.delete();
tempDir.mkdir();
LOGGER.info("writing to: %s", tempDir);
MiniAccumuloConfig miniAccumuloConfig = new MiniAccumuloConfig(tempDir, ACCUMULO_PASSWORD);
miniAccumuloConfig.setZooKeeperStartupTime(60000);
accumulo = new MiniAccumuloCluster(miniAccumuloConfig);
accumulo.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
AccumuloResource.this.stop();
} catch (Exception e) {
System.out.println("Failed to stop Accumulo test cluster");
}
}
});
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project gora by apache.
the class GoraAccumuloTestDriver method setUpClass.
@Override
public void setUpClass() throws IOException, InterruptedException {
log.info("Starting Accumulo MiniAccumuloCluster...");
try {
tmpDir.create();
MiniAccumuloConfig miniCfg = new MiniAccumuloConfig(tmpDir.getRoot(), PASSWORD);
miniCfg.setInstanceName("goraTest");
miniCfg.setZooKeeperPort(56321);
cluster = new MiniAccumuloCluster(miniCfg);
cluster.start();
} catch (Exception e) {
LOG.error("Error starting Accumulo MiniAccumuloCluster: {}", e.getMessage());
// cleanup
tearDownClass();
}
}
Aggregations