Search in sources :

Example 6 with MiniAccumuloConfig

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();
    }));
}
Also used : MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) MiniAccumuloConfig(org.apache.accumulo.minicluster.MiniAccumuloConfig) File(java.io.File)

Example 7 with MiniAccumuloConfig

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");
            }
        }
    });
}
Also used : MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) MiniAccumuloConfig(org.apache.accumulo.minicluster.MiniAccumuloConfig) VertexiumException(org.vertexium.VertexiumException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 8 with MiniAccumuloConfig

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();
    }
}
Also used : MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) MiniAccumuloConfig(org.apache.accumulo.minicluster.MiniAccumuloConfig) IOException(java.io.IOException)

Aggregations

MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)8 MiniAccumuloConfig (org.apache.accumulo.minicluster.MiniAccumuloConfig)8 File (java.io.File)5 IOException (java.io.IOException)2 Connector (org.apache.accumulo.core.client.Connector)2 RyaClient (org.apache.rya.api.client.RyaClient)2 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)2 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 AlreadyInitializedException (org.apache.fluo.api.client.FluoAdmin.AlreadyInitializedException)1 TableExistsException (org.apache.fluo.api.client.FluoAdmin.TableExistsException)1 MiniFluo (org.apache.fluo.api.mini.MiniFluo)1 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)1 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)1 AccumuloIndexingConfiguration (org.apache.rya.indexing.accumulo.AccumuloIndexingConfiguration)1 ClientCnxn (org.apache.zookeeper.ClientCnxn)1 BeforeClass (org.junit.BeforeClass)1 Statement (org.openrdf.model.Statement)1