struct CassCluster
A cluster object describes the configuration of the Cassandra cluster and is used to construct a session instance. Unlike other DataStax drivers the cluster object does not maintain the control connection.
Functions
CassCluster *
cass_cluster_new
( )Creates a new cluster.
void
cass_cluster_free
( cluster )Frees a cluster instance.
CassError
cass_cluster_set_contact_points
( cluster, contact_points )Sets/Appends contact points. This MUST be set. The first call sets the contact points and any subsequent calls appends additional contact points. Passing an empty string will clear the contact points. White space is striped from the contact points.
Examples: “127.0.0.1” “127.0.0.1,127.0.0.2”, “server1.domain.com”
CassError
cass_cluster_set_port
( cluster, port )Sets the port.
Default: 9042
void
cass_cluster_set_ssl
( cluster, ssl )Sets the SSL context and enables SSL.
CassError
cass_cluster_set_protocol_version
( cluster, protocol_version )Sets the protocol version. This will automatically downgrade if to protocol version 1.
Default: 2
CassError
cass_cluster_set_num_threads_io
( cluster, num_threads )Sets the number of IO threads. This is the number of threads that will handle query requests.
Default: 1
CassError
cass_cluster_set_queue_size_io
( cluster, queue_size )Sets the size of the the fixed size queue that stores pending requests.
Default: 4096
CassError
cass_cluster_set_queue_size_event
( cluster, queue_size )Sets the size of the the fixed size queue that stores events.
Default: 4096
CassError
cass_cluster_set_queue_size_log
( cluster, queue_size )Sets the size of the the fixed size queue that stores log messages.
Default: 4096
CassError
cass_cluster_set_core_connections_per_host
( cluster, num_connections )Sets the number of connections made to each server in each IO thread.
Default: 1
CassError
cass_cluster_set_max_connections_per_host
( cluster, num_connections )Sets the maximum number of connections made to each server in each IO thread.
Default: 2
void
cass_cluster_set_reconnect_wait_time
( cluster, wait_time )Sets the amount of time to wait before attempting to reconnect.
Default: 2000 milliseconds
CassError
cass_cluster_set_max_concurrent_creation
( cluster, num_connections )Sets the maximum number of connections that will be created concurrently. Connections are created when the current connections are unable to keep up with request throughput.
Default: 1
CassError
cass_cluster_set_max_concurrent_requests_threshold
( cluster, num_requests )Sets the threshold for the maximum number of concurrent requests in-flight on a connection before creating a new connection. The number of new connections created will not exceed max_connections_per_host.
Default: 100
CassError
cass_cluster_set_max_requests_per_flush
( cluster, num_requests )Sets the maximum number of requests processed by an IO worker per flush.
Default: 128
CassError
cass_cluster_set_write_bytes_high_water_mark
( cluster, num_bytes )Sets the high water mark for the number of bytes outstanding on a connection. Disables writes to a connection if the number of bytes queued exceed this value.
Default: 64 KB
CassError
cass_cluster_set_write_bytes_low_water_mark
( cluster, num_bytes )Sets the low water mark for number of bytes outstanding on a connection. After exceeding high water mark bytes, writes will only resume once the number of bytes fall below this value.
Default: 32 KB
CassError
cass_cluster_set_pending_requests_high_water_mark
( cluster, num_requests )Sets the high water mark for the number of requests queued waiting for a connection in a connection pool. Disables writes to a host on an IO worker if the number of requests queued exceed this value.
Default: 128 * max_connections_per_host
CassError
cass_cluster_set_pending_requests_low_water_mark
( cluster, num_requests )Sets the low water mark for the number of requests queued waiting for a connection in a connection pool. After exceeding high water mark requests, writes to a host will only resume once the number of requests fall below this value.
Default: 64 * max_connections_per_host
void
cass_cluster_set_connect_timeout
( cluster, timeout_ms )Sets the timeout for connecting to a node.
Default: 5000 milliseconds
void
cass_cluster_set_request_timeout
( cluster, timeout_ms )Sets the timeout for waiting for a response from a node.
Default: 12000 milliseconds
void
cass_cluster_set_credentials
( cluster, username, password )Sets credentials for plain text authentication.
void
cass_cluster_set_load_balance_round_robin
( cluster )Configures the cluster to use round-robin load balancing.
The driver discovers all nodes in a cluster and cycles through them per request. All are considered ‘local’.
CassError
cass_cluster_set_load_balance_dc_aware
( cluster, local_dc, used_hosts_per_remote_dc, allow_remote_dcs_for_local_cl )Configures the cluster to use DC-aware load balancing. For each query, all live nodes in a primary ‘local’ DC are tried first, followed by any node from other DCs.
Note: This is the default, and does not need to be called unless switching an existing from another policy or changing settings. Without further configuration, a default local_dc is chosen from the first connected contact point, and no remote hosts are considered in query plans. If relying on this mechanism, be sure to use only contact points from the local DC.
void
cass_cluster_set_token_aware_routing
( cluster, enabled )Configures the cluster to use Token-aware request routing, or not.
Default is cass_true (enabled).
This routing policy composes the base routing policy, routing requests first to replicas on nodes considered ‘local’ by the base load balancing policy.
void
cass_cluster_set_tcp_nodelay
( cluster, enabled )Enable/Disable Nagel’s algorithm on connections.
Default: cass_false (disabled).
void
cass_cluster_set_tcp_keepalive
( cluster, enabled, delay_secs )Enable/Disable TCP keep-alive
Default: cass_false (disabled).