Example usage for org.apache.cassandra.service CassandraDaemon init

List of usage examples for org.apache.cassandra.service CassandraDaemon init

Introduction

In this page you can find the example usage for org.apache.cassandra.service CassandraDaemon init.

Prototype

public void init(String[] arguments) throws IOException 

Source Link

Document

Initialize the Cassandra Daemon based on the given <a href="http://commons.apache.org/daemon/jsvc.html">Commons Daemon</a>-specific arguments.

Usage

From source file:com.github.pmerienne.trident.state.cassandra.embedded.CassandraEmbeddedServerStarter.java

License:Apache License

public void start(final CassandraConfig config) {

    if (isAlreadyRunning()) {
        log.info("Cassandra is already running, not starting new one");
        return;//ww  w  .java 2  s  .  c om
    }

    log.info("Starting Cassandra...");
    config.write();
    System.setProperty("cassandra.config", "file:" + config.getConfigFile().getAbsolutePath());
    System.setProperty("cassandra-foreground", "true");

    final CountDownLatch startupLatch = new CountDownLatch(1);
    executor = Executors.newSingleThreadExecutor();
    executor.execute(new Runnable() {
        @Override
        public void run() {
            try {
                CassandraDaemon cassandraDaemon = new CassandraDaemon();
                cassandraDaemon.init(null);
                cassandraDaemon.start();
                startupLatch.countDown();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            // cassandraDaemon.activate();
        }
    });

    try {
        startupLatch.await(30, SECONDS);
    } catch (InterruptedException e) {
        log.error("Timeout starting Cassandra embedded", e);
        throw new IllegalStateException("Timeout starting Cassandra embedded", e);
    }
}