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

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

Introduction

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

Prototype

public void start() 

Source Link

Document

Start the Cassandra Daemon, assuming that it has already been initialized via #init(String[]) Hook for JSVC

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;//w  ww .j a  va2  s  .co m
    }

    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);
    }
}