-
Notifications
You must be signed in to change notification settings - Fork 39
UsingJava
Add the following dependency to your pom.xml
:
<dependency>
<groupId>org.opennms.newts</groupId>
<artifactId>newts-cassandra</artifactId>
<version>1.3.1</version>
</dependency>
Additionally, if you wish to enable search lookups and indexing, add the following as well:
<dependency>
<groupId>org.opennms.newts</groupId>
<artifactId>newts-cassandra-search</artifactId>
<version>1.3.1</version>
</dependency>
Newts modules register any Cassandra schema they require using the Java
ServiceLoader mechanism. You can use a ServiceLoader to discover these
schemas, and the org.opennms.newts.cassandra.SchemaManager
class to
apply them to a running Cassandra cluster. For example:
// Find all registered instances of Schema.class
ServiceLoader<Schema> schemas = ServiceLoader.load(Schema.class);
// Create each discovered schema
try (SchemaManager m = new SchemaManager(keyspace, host, port)) {
for (Schema s : schemas)
m.create(s, true);
}
If necessary (if an existing keyspace does not exist), these schemas
will create a keyspace using Cassandra's SimpleStategy
and a replication
factor of 1 (read: no replication). For all but the most trivial of test
installs, this is probably not what you want. Therefore, you can either
a) create your keyspace beforehand, or b) alter the automatically generated
one after the fact.
The Java API Reference.
- Getting Started
- Data Model
- Running a REST Service
- Using the Java API
- Aggregation
- Search
- API Reference * Java * REST
- Hacking Newts