Cassandra Writer writes data to Cassandra. This topic describes the data types and parameters that are supported by Cassandra Writer and how to configure Cassandra Writer by using the code editor.

Background information

Cassandra Writer connects to a Cassandra instance by using the Java Database Connectivity (JDBC) driver of DataStax, generates an INSERT CQL statement based on the settings of the parameters such as table and column that you configured, and executes the statement to write data to Cassandra.

Data Integration is an engine program based on which data synchronization nodes are run. When Cassandra Writer writes data to Cassandra, Cassandra Writer converts data from data types supported by Data Integration to data types supported by Cassandra.

Limits

  • Cassandra Writer supports only exclusive resource groups for Data Integration and can be configured only by using the code editor.
  • Cassandra Writer cannot write data of the counter type or a custom type to Cassandra.

Parameters

The following table describes the parameters that are supported by Cassandra Writer.
Parameter Description Required Default value
host The domain names or IP addresses of the Cassandra database to which you want to write data. Separate multiple domain names or IP addresses with commas (,). Yes No default value
port The port number of the Cassandra database. Yes 9042
username The username that you use to connect to the database. No No default value
password The password that you use to connect to the database. No No default value
useSSL Specifies whether to use SSL to establish connections. Valid values:
  • true
  • false
No false
connectionsPerHost The number of connections that can be established for each node of the server. No 8
maxPendingPerConnection The maximum number of requests that are allowed for each connection. No 128
keyspace The keyspace to which the destination table belongs.
Note A keyspace is an object that stores column families and user-defined types.
Yes No default value
table The name of the destination table. Yes No default value
column The names of the columns to which you want to write data.

You can set this parameter to a specific column name or to writetime(). If you set this parameter to writetime(), the system enters the timestamp at which data is written in the columns specified by the column parameter.

Yes No default value
consistancyLevel The level of data consistency. Valid values:
  • ONE
  • QUORUM
  • LOCAL_QUORUM
  • EACH_QUORUM
  • ALL
  • ANY
  • TWO
  • THREE
  • LOCAL_ONE
No LOCAL_QUORUM
batchSize The number of data records to write at a time. Limits:
  • The value of this parameter cannot exceed 65535.
  • The size of data records to write at a time depends on the value of the batch_size_fail_threshold_in_kb parameter of the server.
  • If the size of data records to write at a time exceeds the value of the batch_size_warn_threshold_in_kb parameter, warn-level logs are generated. Warn-level logs do not affect data write operations and can be ignored.
If data records fail to be written at a time, Cassandra Writer writes the data records one at a time.
No 1

Configure Cassandra Writer by using the code editor

In the following code, a synchronization node is configured to write in-memory data to Cassandra:
{
  "job": {
    "setting": {
      "speed": {
        "channel": 5
      }
    },
    "content": [
      {
        "reader": {
          "name": "streamreader",
          "parameter": {
            "column": [
              {"value":"name","type": "string"},
              {"value":"false","type":"bool"},
              {"value":"1988-08-08 08:08:08","type":"date"},
              {"value":"addr","type":"bytes"},
              {"value":1.234,"type":"double"},
              {"value":12345678,"type":"long"},
              {"value":2.345,"type":"double"},
              {"value":3456789,"type":"long"},
              {"value":"4a0ef8c0-4d97-11d0-db82-ebecdb03ffa5","type":"string"},
              {"value":"value","type":"bytes"},
              {"value":"-838383838,37377373,-383883838,27272772,393993939,-38383883,83883838,-1350403181,817650816,1630642337,251398784,-622020148","type":"string"},
            ],
           "sliceRecordCount": 10000000
          }
        },
        "writer": {
          "name": "cassandrawriter",
          "parameter": {
            "host": "localhost",
            "port": 9042,
            "useSSL": false,
            "keyspace": "stresscql",
            "table": "dst",
            "batchSize":10,
            "column": [
              "name",
              "choice",
              "date",
              "address",
              "dbl",
              "lval",
              "fval",
              "ival",
              "uid",
              "value",
              "listval"
            ]
          }
        }
      }
    ]
  }
}

Data types

Cassandra Writer can convert data from data types supported by Data Integration to data types supported by Cassandra. The following table provides the mappings between Data Integration data types and Cassandra data types.
Data Integration data type Cassandra data type
LONG
  • INT
  • TINYINT
  • SMALLINT
  • VARINT
  • BIGINT
  • TIME
DOUBLE
  • FLOAT
  • DOUBLE
  • DECIMAL
STRING
  • ASCII
  • VARCHAR
  • TEXT
  • UUID
  • TIMEUUID
  • DURATION
  • LIST
  • MAP
  • SET
  • TUPLE
  • UDT
  • INET
DATE
  • DATE
  • TIMESTAMP
BOOLEAN BOOLEAN
BYTES BLOB