List of usage examples for org.apache.cassandra.service CassandraDaemon deactivate
public void deactivate()
From source file:com.facebook.presto.cassandra.EmbeddedCassandra.java
License:Apache License
public static synchronized void start() throws Exception { if (initialized) { return;/*w ww . j a v a2 s . c o m*/ } log.info("Starting cassandra..."); System.setProperty("cassandra.config", "file:" + prepareCassandraYaml()); System.setProperty("cassandra-foreground", "true"); System.setProperty("cassandra.native.epoll.enabled", "false"); CassandraDaemon cassandraDaemon = new CassandraDaemon(); cassandraDaemon.activate(); Cluster.Builder clusterBuilder = Cluster.builder().withProtocolVersion(V3).withClusterName("TestCluster") .addContactPointsWithPorts(ImmutableList.of(new InetSocketAddress(HOST, PORT))) .withMaxSchemaAgreementWaitSeconds(30); ReopeningCluster cluster = new ReopeningCluster(clusterBuilder::build); CassandraSession session = new NativeCassandraSession("EmbeddedCassandra", JsonCodec.listJsonCodec(ExtraColumnMetadata.class), cluster, new Duration(1, MINUTES)); try { checkConnectivity(session); } catch (RuntimeException e) { cluster.close(); cassandraDaemon.deactivate(); throw e; } EmbeddedCassandra.session = session; initialized = true; }
From source file:io.prestosql.plugin.cassandra.EmbeddedCassandra.java
License:Apache License
public static synchronized void start() throws Exception { if (initialized) { return;// w ww. jav a 2s . c o m } log.info("Starting cassandra..."); System.setProperty("cassandra.config", "file:" + prepareCassandraYaml()); System.setProperty("cassandra-foreground", "true"); System.setProperty("cassandra.native.epoll.enabled", "false"); CassandraDaemon cassandraDaemon = new CassandraDaemon(); cassandraDaemon.activate(); Cluster.Builder clusterBuilder = Cluster.builder().withProtocolVersion(V3).withClusterName("TestCluster") .addContactPointsWithPorts(ImmutableList.of(new InetSocketAddress(HOST, PORT))) .withMaxSchemaAgreementWaitSeconds(30); ReopeningCluster cluster = new ReopeningCluster(clusterBuilder::build); CassandraSession session = new NativeCassandraSession(JsonCodec.listJsonCodec(ExtraColumnMetadata.class), cluster, new Duration(1, MINUTES)); try { checkConnectivity(session); } catch (RuntimeException e) { cluster.close(); cassandraDaemon.deactivate(); throw e; } EmbeddedCassandra.session = session; initialized = true; }