I'm working on a monitoring application that periodically verifies the execution status of Cassandra nodes. The application dynamically creates Cassandra connections by reading multiple configurations from a data center environment during its bootstrap process and creates CqlSession objects.
In the configuration, the contact points for Cassandra nodes are defined using hostnames rather than IP addresses.
However, I've encountered an issue where the Cassandra Java driver is translating these hostnames into IP addresses only, rather than maintaining both the hostname and IP address. When a sample query is issued to nodes where the endpoint is represented as an IP address only, the requests fail with the following error: 'com.datastax.oss.driver.api.core.NodeUnavailableException: No connection was available to Node(endPoint=/10.xxx.xxx.xx:9042)'' On the other hand, nodes with endpoints configured as both hostname and IP address (e.g., 'my_cassandra_node_host_name/10.xxx.xxx.xx:9042') can handle the requests without issues.
My questions are:
- Why is the Cassandra Java driver duplicating node connections, with some nodes represented only by IP address (e.g., '/ip_address:9042') and others by both hostname/IP address (e.g., 'hostname/ip_address:9042')?
- Why are nodes represented by IP addresses only causing request failures?
- How can I configure the Cassandra Java driver to consistently return nodes with valid endpoints (preferably maintaining both hostname and IP address)?
Any advice or insights would be greatly appreciated.
Thanks! AKV
