scylladb / java-driver

ScyllaDB Java Driver for ScyllaDB and Apache Cassandra, based on the DataStax Java Driver
Apache License 2.0
61 stars 37 forks source link

3.x: Reconnect to original contact points #344

Open Bouncheck opened 1 week ago

Bouncheck commented 1 week ago

Copied from commit message:

Add option to consider initial contact points during reconnection

When control connection tries to reconnect usually it considers only nodes provided by load balancing policy. Usually those do not include what was initially passed to the driver but the recently seen alive nodes. In some setups the IPs can keep changing so it may be useful to have an option to try initial contact points as one of the options during reconnection. Mainly if the contact point is a hostname.

This change adds the option to the QueryOptions to control that behaviour and adds necessary logic to ControlConnection class. It is disabled by default, meaning that default behaviour remains unchanged.

Additionally adds org.burningwave tools dependency. This dependency has features that allow for easier host resolution mocking.

Adds MappedHostResolverProvider class for testing as a single entry point for controlling hostname resolution.

Adds an option to CcmBridge Builder to specify cluster name. Driver checks the cluster name when reconnecting so it will refuse to reconnect to a different CcmBridge auto-generated name.

Bouncheck commented 1 week ago

I believe this should resolve #224 If the contact point is passed the following way

cluster =
          Cluster.builder()
              .addContactPointsWithPorts(
                  InetSocketAddress.createUnresolved("some.hostname", 9042))
...

then with this change the driver should keep trying to reach some.hostname when no other nodes respond.

Bouncheck commented 5 days ago

Pushed v2