Search in sources :

Example 1 with Settings

use of com.github.nosan.embedded.cassandra.Settings in project embedded-cassandra by nosan.

the class CassandraExamples method quickStart.

private void quickStart() {
    // tag::quick-start[]
    Cassandra cassandra = new CassandraBuilder().build();
    cassandra.start();
    try {
        Settings settings = cassandra.getSettings();
        try (CqlSession session = CqlSession.builder().addContactPoint(new InetSocketAddress(settings.getAddress(), settings.getPort())).withLocalDatacenter("datacenter1").build()) {
            CqlScript.ofClassPath("schema.cql").forEachStatement(session::execute);
        }
    } finally {
        cassandra.stop();
    }
// end::quick-start[]
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Cassandra(com.github.nosan.embedded.cassandra.Cassandra) CassandraBuilder(com.github.nosan.embedded.cassandra.CassandraBuilder) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Settings(com.github.nosan.embedded.cassandra.Settings)

Aggregations

CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 Cassandra (com.github.nosan.embedded.cassandra.Cassandra)1 CassandraBuilder (com.github.nosan.embedded.cassandra.CassandraBuilder)1 Settings (com.github.nosan.embedded.cassandra.Settings)1 InetSocketAddress (java.net.InetSocketAddress)1