How to connect my Cassandra Java client to a Cassandra cluster, and not to a specific node?

I am trying to learn Cassandra and set up a Cassandra 4 node cluster. I wrote a client in Java using the Hector, which currently connects to a hard-coded single node in a cluster. Ideally, I would like my client to connect to a "cluster", and not to a specific node .... therefore, if any of the 4 nodes does not work, the client will still connect to something. From the point of view of the client application, how does it work? I can't seem to find a good explanation.

My Hector connection string is currently, I need to specify a specific node here:

Cluster c = getOrCreateCluster("Test Cluster", cassandraNode1:9160);

My Cassandra nodes have everything configured with my rpc_address: 0.0.0.0

+3
source share
2

CassandraHostConfigurator getOrCreateCluster(), , :

  public CassandraHostConfigurator(String hosts) {
    this.hosts = hosts;
  }

  ...

  String[] hostVals = hosts.split(",");

  CassandraHost[] cassandraHosts = new CassandraHost[hostVals.length];
  ...
+5

CassandraHostConfigurator # setAutoDiscoverHosts #setUseAutoDiscoverAtStartup, (), , Thrift API describe_keyspaces. , .

( ) , . JMX, , Hector.

+3

All Articles