-
Notifications
You must be signed in to change notification settings - Fork 133
IGNITE-26893 Java thin: improve DNS resolution logic. #7031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: AlexLev-Tor <[email protected]>
…lientConfiguration.
…to ignite-26893 # Conflicts: # docs/_docs/index.adoc
…-26893 # Conflicts: # modules/client/src/main/java/org/apache/ignite/internal/client/TcpIgniteClient.java # modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
| // Special handling for "localhost" to avoid unnecessary DNS resolution. | ||
| if ("localhost".equalsIgnoreCase(addr.host())) { | ||
| map.merge(InetSocketAddress.createUnresolved(addr.host(), addr.port()), 1, Integer::sum); | ||
|
|
||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, localhost can be customized in the hosts file for various reasons. And the OS should deal with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're right. Potentially, we have more than one name (localhost, InetAddress.getLocalHost().getHostName()) for the loopback interface.
It might be a problem since the client will try to connect to all loopback addresses (127.0.0.1, 0:0:0:0:0:0:0:1) if you set "localhost".
| } | ||
|
|
||
| for (InetAddress inetAddr : addressResolver.getAllByName(addr.host())) { | ||
| // Preserve unresolved address if the resolved address equals to the original host string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate, why do we need this special case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All IP addresses remain unresolved to preserve connection order in tests. Without this fix, we need to fix RequestBalancingTest, ClientPartitionManagerTest, ...
| return ranges.stream() | ||
| .map(p -> InetSocketAddress.createUnresolved(p.host(), p.port())) | ||
| .collect(Collectors.toMap(a -> a, a -> 1, Integer::sum)); | ||
| var map = new HashMap<InetSocketAddress, Integer>(parsedAddrs.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.apache.ignite.internal.util.IgniteUtils#newHashMap need to be used if you want to predict the sizing
https://issues.apache.org/jira/browse/IGNITE-26893
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
The Review Checklist
- There is a single JIRA ticket related to the pull request.
- The web-link to the pull request is attached to the JIRA ticket.
- The JIRA ticket has the Patch Available state.
- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
Notes