Implementation:Risingwavelabs Risingwave CassandraConfig
| Property | Value |
|---|---|
| File | java/connector-node/risingwave-sink-cassandra/src/main/java/com/risingwave/connector/CassandraConfig.java
|
| Language | Java |
| Lines | 128 |
| Category | Configuration |
| Package | com.risingwave.connector
|
Overview
CassandraConfig is a configuration class for the Cassandra sink connector in RisingWave. It extends CommonSinkConfig and holds connection parameters such as URL, keyspace, table, datacenter, and authentication credentials. The class uses Jackson @JsonProperty annotations for deserialization of sink configuration properties from the RisingWave connector framework. It also provides builder-style setter methods with validation for optional parameters like maxBatchRows and requestTimeoutMs.
Code Reference
Source Location
Signature
public class CassandraConfig extends CommonSinkConfig {
@JsonCreator
public CassandraConfig(
@JsonProperty(value = "cassandra.url") String url,
@JsonProperty(value = "cassandra.keyspace") String keyspace,
@JsonProperty(value = "cassandra.table") String table,
@JsonProperty(value = "cassandra.datacenter") String datacenter,
@JsonProperty(value = "type") String type)
}
Imports
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.risingwave.connector.api.sink.CommonSinkConfig;
I/O Contract
Inputs
The constructor accepts the following JSON-mapped properties:
| Property Key | Field | Required | Default |
|---|---|---|---|
cassandra.url |
url |
Yes | N/A |
cassandra.keyspace |
keyspace |
Yes | N/A |
cassandra.table |
table |
Yes | N/A |
cassandra.datacenter |
datacenter |
Yes | N/A |
type |
type |
Yes | N/A |
cassandra.username |
username |
No | null
|
cassandra.password |
password |
No | null
|
cassandra.max_batch_rows |
maxBatchRows |
No | 512
|
cassandra.request_timeout_ms |
requestTimeoutMs |
No | 2000
|
Outputs
The class provides getter methods for all fields. The table field is converted via CassandraUtil.convertCQLIdentifiers() during construction, wrapping the table name in double quotes for CQL identifier safety.
Validation
withMaxBatchRows(Integer)throwsIllegalArgumentExceptionif the value is less than 1 or greater than 65536.withRequestTimeoutMs(Integer)throwsIllegalArgumentExceptionif the value is less than 1.
Usage Examples
// Deserialization from a properties map via Jackson
ObjectMapper mapper = new ObjectMapper();
CassandraConfig config = mapper.convertValue(tableProperties, CassandraConfig.class);
// Accessing configuration values
String url = config.getUrl();
String keyspace = config.getKeyspace();
String table = config.getTable();
// Builder-style optional configuration
config.withUsername("myuser")
.withPassword("mypassword")
.withMaxBatchRows(1024)
.withRequestTimeoutMs(5000);
Related Pages
- CassandraFactory - Factory that uses this configuration to create and validate Cassandra sinks
- CassandraUtil - Utility class referenced for CQL identifier conversion
- SinkFactory CreateWriter - General sink writer creation pattern