feat: add EndPoint.resolveAll() for multi-address DNS expansion (DRIVER-201) — Part 2/2#890
Draft
nikagra wants to merge 1 commit into
Draft
Conversation
…ER-201) Addresses the endpoint-API aspect of DRIVER-201. Problem: EndPoint.resolve() returns a single SocketAddress. When a hostname maps to multiple IPs, the driver can only try the first one and fails with AllNodesFailedException if it is unreachable — the remaining IPs are invisible to the connection layer. Solution (per @dkropachev's architectural direction): - Deprecate EndPoint.resolve(). Add EndPoint.resolveAll() with a default implementation that wraps resolve() in a single-element array for backward compatibility with third-party implementations. - DefaultEndPoint.resolveAll(): if the stored InetSocketAddress is unresolved, calls InetAddress.getAllByName() to expand the hostname to all known IPs, returning one InetSocketAddress per IP. Falls back to the single-element unresolved address if DNS fails, so the connect attempt surfaces a descriptive error rather than returning empty. - SniEndPoint.resolveAll(): re-resolves the proxy hostname on each call and returns all A-records sorted by IP, enabling the caller to try each proxy address in sequence. - ClientRoutesEndPoint.resolveAll(): delegates to resolve() (single- address topology-monitor lookup) and wraps in a one-element array. - ChannelFactory.connect(): replaced endPoint.resolve() with endPoint.resolveAll(). Iterates through the returned candidates via tryNextCandidate(); on per-address failure logs and tries the next; only fails the overall resultFuture when all candidates are exhausted. Protocol-version negotiation (downgrade retries) is scoped to the same address via connectToAddress(), which is semantically correct. Tests: - DefaultEndPointTest: 3 new cases — already-resolved passthrough, unresolved hostname expansion, unresolvable hostname fallback. - SniEndPointTest: new class with cases for resolveAll() happy path, unresolvable host exception, and resolve() sanity check. - All 13 existing ChannelFactory tests continue to pass (LocalEndPoint uses the default single-element resolveAll() via the interface default).
nikagra
added a commit
to nikagra/java-driver
that referenced
this pull request
May 15, 2026
…VER-201) newControlReconnectionQueryPlan() now creates copies of the original contact-point nodes (with their unresolved hostname endpoints) instead of synthetic nodes with resolved IPs. This ensures the control channel carries the hostname endpoint, which is preserved in metadata after topology refresh. DNS expansion for connection fallback is handled by ChannelFactory (PR scylladb#890), so the control-reconnection path does not need to inject resolved-IP nodes into the query plan. Also adds getContactPoints() stub back to LoadBalancingPolicyWrapperTest so tests that cover the control-reconnect path continue to pass.
nikagra
added a commit
to nikagra/java-driver
that referenced
this pull request
May 15, 2026
Before-init query plan now uses getContactPoints() (original unresolved hostname nodes) instead of getResolvedContactPoints(). The DNS expansion to all IPs happens at the ChannelFactory level (PR scylladb#890), so expanding here was redundant and broke should_connect_with_mocked_hostname by replacing hostname endpoints with resolved-IP endpoints. Also remove the should_connect_when_first_dns_entry_is_non_responsive integration test from this PR; it belongs in PR scylladb#890 where ChannelFactory expansion actually enables it to pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`EndPoint.resolve()` returns a single `SocketAddress`. When a hostname maps to multiple IPs, the driver can only try the first one at the connection layer. If that IP is unreachable the driver fails with `AllNodesFailedException` even though other IPs are available.
Fixes DRIVER-201 at the general connection layer.
Changes
`EndPoint` interface
`DefaultEndPoint`
`SniEndPoint`
`ClientRoutesEndPoint`
`ChannelFactory`
Tests