Cassandra plugin

Overview

The Cassandra plugin connects QALIPSIS to Apache Cassandra.

Technologies addressed
Dependency

io.qalipsis.plugin:qalipsis-plugin-cassandra

Namespace in scenario

cassandra()

Client library

DataStax: refer to the DataStax.

Datastax is a modern, feature-rich and highly tunable Java client library for Apache Cassandra using Cassandra’s binary protocol and Cassandra Query Language.

Supported steps
  • poll: polls the newest data periodically.

  • save: saves records generated from the input and step context.

  • search: searches records and builds a query from the input and step context.

Example scenarios using a combination of Cassandra supported steps are provided on Github.

Poll step

The poll step within the Cassandra plugin polls the newest records from the database table.

Ancestor

Scenario or Step

Functionality

The poll step is created only once in a scenario; it is then used throughout the scenario as called. The poll step within the Cassandra plugin uses a strategy of “delivered at least once."

Example
cassandra().poll {
    connect {
        servers = listOf("localhost:9042")
        keySpace = "iot"
        datacenterName = "datacenter1"
    }
    query("SELECT deviceid, timestamp, batterylevel FROM batteryState WHERE company = ? ORDER BY timestamp")
    parameters("ACME Inc.")
    tieBreaker {
        name = "timestamp"
        type = GenericType.INSTANT
    }
    pollDelay(Duration.ofSeconds(1))
}
Notable parameters
  • connect (required): configures the connection to Apache Cassandra

  • keyspace (required): the outermost object that determines how data replicates on nodes.

  • query (required): defines the prepared statement to execute when polling.

  • parameters (optional): binds values to the clauses of the prepared query.

  • tieBreaker (required): repeats the first column used for sorting and comparison ( or >=, depending on the ascending or descending order).

  • pollDelay (required): specifies the delay between query executions.

  • broadcast (optional): specifies the broadcast parameters for the step.

Tips
  • Use the poll step with a left join operator to verify the values saved by your tested system in the database.

  • query requires at least one sorting field (tiebreaker in the example) to filter the newest results and not fetch the same records repeatedly.

  • The latest known value for tiebreaker is used to filter out values already received from the database.

Reference documentation

Refer to the Apache Cassandra documentation for further parameter and configuration information.

Save step

The save step within the Cassandra plugin persists records into a cassandra database using the save query with Cassandra Query Language (CQL).

Ancestor

Step

Functionality

The save step’s input and step context are used to generate documents to save into a database.

Example
.cassandra()
.save {
    connect {
        servers = listOf("localhost:9042")
        keyspace = "iot"
        datacenterName = "datacenter1"
    }

    table { _, _ ->
        "batteryState"
    }

    columns { _, _ ->
        listOf(
            "company",
            "deviceid",
            "timestamp,
            "batterylevel"
        )
    }

    rows { _, input ->
        listOf(
            CassandraSaveRow(
                "'ACME Inc.'",
                "'${input.deviceId}'",
                "'${input.timestamp}'",
                input.batteryLevel
            )
        )
    }
}
Notable parameters
  • connect (required): configures the connection to Apache Cassandra.

  • keyspace (required): the outermost object that determines how data replicates on nodes.

Tips
  • Use the save step after a collect step to reduce the number of queries executed onto the database and reduce the load your scenario generates on it.

  • The save step is extremely flexible; table, rows, and columns depend on the context and input value received from the previous step.

Reference documentation

Refer to the Apache Cassandra documentation for further parameter and configuration information.

Search step

The search step within the Cassandra plugin searches records in the database using a search query.

Ancestor

step

Functionality

The search step’s input and step context are used to complete the search; the list of results is then forwarded to the next step(s).

Example
cassandra().search {
    name = "search"

    connect {
        servers = listOf("localhost:9042")
        keyspace = "iot"
        datacenterName = "datacenter1"
    }
    query { _, _ ->
        "SELECT * FROM batteryState WHERE company= ? AND deviceid = ? AND timestamp = ?"
    }
    parameters { _, input ->
        listOf("ACME Inc.", input.input.deviceId, input.input.timestamp)
    }
}
Notable parameters
  • connect (required): configures the connection to Apache Cassandra.

  • keyspace(required): the outermost object that determines how data replicates on nodes.

  • query (required): defines the prepared statement to execute when searching.

  • parameters: (optional): binds values to the clauses of the prepared query.

Tips
  • Use the search step after a collect() step to reduce the number of queries executed onto the database and to reduce the load the scenario generates on the test system.

  • The query parameter may contain ordering clauses.

Reference documentation
  • Refer to the Apache Cassandra documentation for further parameter and configuration information.