Cassandra plugin
Overview
The Cassandra plugin connects QALIPSIS to Apache Cassandra.
- Technologies addressed
-
-
Cassandra: Apache Cassandra
-
Cassandra Query Language: The Cassandra Query Language (CQL)
-
DataStax Driver: DataStax.
-
- 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
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
pollstep is created only once in a scenario; it is then used throughout the scenario as called. Thepollstep 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
pollstep with a left join operator to verify the values saved by your tested system in the database. -
queryrequires at least one sorting field (tiebreakerin the example) to filter the newest results and not fetch the same records repeatedly. -
The latest known value for
tiebreakeris 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
savestep’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
savestep after acollectstep to reduce the number of queries executed onto the database and reduce the load your scenario generates on it. -
The
savestep 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
searchstep’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
searchstep after acollect()step to reduce the number of queries executed onto the database and to reduce the load the scenario generates on the test system. -
The
queryparameter may contain ordering clauses.
-
- Reference documentation
-
-
Refer to the Apache Cassandra documentation for further parameter and configuration information.
-