use of org.apache.accumulo.minicluster.MiniAccumuloConfig 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.MiniAccumuloConfig 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.MiniAccumuloConfig 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