Cassandra

Cassandra Store

The Cassandra store implementation writes state into an external Cassandra database. To use it, ensure that the nstream.persist.store.cassandra module is present on the module path. It can be used both directly and through the key-value adapter. The database schema used in both cases is identical so it is possible to switch between them.

Dependencies

Gradle

implementation 'io.nstream:nstream-persist-kernel:4.11.19'
implementation 'io.nstream:nstream-persist-kv:4.11.19'
implementation 'io.nstream:nstream-store-cassandra:4.11.19'

Maven

<dependency>
  <groupId>io.nstream</groupId>
  <artifactId>nstream-persist-kernel</artifactId>
  <version>4.11.19</version>
  <type>module</type>
</dependency>
<dependency>
  <groupId>io.nstream</groupId>
  <artifactId>nstream-persist-kv</artifactId>
  <version>4.11.19</version>
  <type>module</type>
</dependency>
<dependency>
  <groupId>io.nstream</groupId>
  <artifactId>nstream-store-cassandra</artifactId>
  <version>4.11.19</version>
  <type>module</type>
</dependency>

N.B. The dependency on nstream-persist-kv is only required if the key-value adapter is used.

Configuration

To use it directly, configure the store as:

storeName: @store {
    implName: "Cassandra"
    parameters: { 
        configurationPath: "/path/to/client_config"
    }
}

and via the key-value adapter:

exampleKvStore: @store {
    implName: KeyValueAdapter
    parameters: {
        implName: Cassandra
        parameters: {
            configurationPath: "/path/to/client_config"
        }
    }
}

In both cases, /path/to/client_config is the path to the Cassandra client configuration file. The Cassandra store implementation uses the Datastax Java Cassandra client internally. See here for instructions on how to provide the configuration.

The configuration path may be omitted which will cause Cassandra to use its default configuration. This will assume that a Cassandra server is available on localhost on the default ports.

Configuration Options Table

Parameter Default Value Description
createSchema false Whether to attempt to create the database schema on startup.
defaultReplication 2 Default replication for created tables.
updateConsistency ONE The consistency level used for writing lane state to the database.
readConsistency ONE The consistency level used for reading lane state from the database.
idUpdateConsistency ALL The consistency level for writing new lane ID metadata to the database.
idReadConsistency ALL The consistency level used for read lane ID metadata from the database.

The names of the consistency levels are an enumeration defined by Cassandra.

Cassandra Schema

Each application has its own keyspace within Cassandra (the name of which is determined by the name of the store). Therefor, multiple NStream applications can coexist in single Cassandra cluster as long as each application uses a different store name.

If createSchema is false, the database schema must already exist in the database. Note also that defaultReplication has no effect in this case.


Nstream is licensed under the Redis Source Available License 2.0 (RSALv2).