Package com.github.nosan.embedded.cassandra
Embedded Cassandra provides an easy way to start and stop Apache Cassandra.
The public API includes the following classes and interfaces:
Cassandra- An interface that represents a Cassandra instance.Version- A class that parses and represents a Cassandra version.CassandraBuilder- A builder class used to configure and create aCassandrainstance.CqlScript- An interface that loads CQL statements from various sources.WorkingDirectoryInitializer- A strategy interface to initialize the working directory.WorkingDirectoryDestroyer- A strategy interface to destroy the working directory.WorkingDirectoryCustomizer- A customizer interface used to modify the working directory.CassandraBuilderConfigurator- A callback interface to configure aCassandraBuilder.
Example:
Cassandra cassandra = new CassandraBuilder().build();
cassandra.start();
try {
Settings settings = cassandra.getSettings();
try (Cluster cluster = Cluster.builder().addContactPoints(settings.getAddress())
.withPort(settings.getPort()).build()) {
Session session = cluster.connect();
CqlScript.ofClassPath("schema.cql").forEachStatement(session::execute);
}
} finally {
cassandra.stop();
}
-
Interface Summary Interface Description Cassandra CassandraBuilderConfigurator A callback interface to configure aCassandraBuilder.CassandraDirectoryProvider Provides the path to the Cassandra directory based on a specified version.DefaultWorkingDirectoryInitializer.CopyStrategy Cassandra file copy strategies.Settings Cassandra settings.WorkingDirectoryCustomizer A callback interface to customize a working directory.WorkingDirectoryDestroyer A strategy interface to destroy the working directory.WorkingDirectoryInitializer A strategy interface for initializing the working directory. -
Class Summary Class Description CassandraBuilder A builder that can be used to configure and createCassandra.DefaultWorkingDirectoryInitializer The default implementation ofWorkingDirectoryInitializerretrieves the Cassandra directory from theCassandraDirectoryProviderand copies all files from the retrieved directory into the working directory, except for the javadoc, doc, and licenses directories.SimpleSeedProviderConfigurator ACassandraBuilderConfiguratorimplementation that configures the `org.apache.cassandra.locator.SimpleSeedProvider` class.Version A representation of a Cassandra version.WebCassandraDirectoryProvider An implementation ofCassandraDirectoryProviderthat downloads and extracts a Cassandra archive from well-known URLs into the specified download directory. -
Exception Summary Exception Description CassandraException An exception thrown by aCassandra.