CassandraHook

Cassandra

Hook used to interact with Cassandra

View Source

Last Updated: Dec. 8, 2020

Access Instructions

Install the Cassandra provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Documentation

Hook used to interact with Cassandra

Contact points can be specified as a comma-separated string in the ‘hosts’ field of the connection.

Port can be specified in the port field of the connection.

If SSL is enabled in Cassandra, pass in a dict in the extra field as kwargs for ssl.wrap_socket(). For example:

{
'ssl_options' : {
'ca_certs' : PATH_TO_CA_CERTS
}
}

Default load balancing policy is RoundRobinPolicy. To specify a different LB policy:

- DCAwareRoundRobinPolicy
{
'load_balancing_policy': 'DCAwareRoundRobinPolicy',
'load_balancing_policy_args': {
'local_dc': LOCAL_DC_NAME, // optional
'used_hosts_per_remote_dc': SOME_INT_VALUE, // optional
}
}
- WhiteListRoundRobinPolicy
{
'load_balancing_policy': 'WhiteListRoundRobinPolicy',
'load_balancing_policy_args': {
'hosts': ['HOST1', 'HOST2', 'HOST3']
}
}
- TokenAwarePolicy
{
'load_balancing_policy': 'TokenAwarePolicy',
'load_balancing_policy_args': {
'child_load_balancing_policy': CHILD_POLICY_NAME, // optional
'child_load_balancing_policy_args': { ... } // optional
}
}

For details of the Cluster config, see cassandra.cluster.

Example DAGs

Improve this module by creating an example DAG.

View Source
  1. Add an `example_dags` directory to the top-level source of the provider package with an empty `__init__.py` file.
  2. Add your DAG to this directory. Be sure to include a well-written and descriptive docstring
  3. Create a pull request against the source code. Once the package gets released, your DAG will show up on the Registry.

Was this page helpful?