Phillippko commented on code in PR #7483:
URL: https://github.com/apache/ignite-3/pull/7483#discussion_r2735970171
##########
modules/network/src/main/java/org/apache/ignite/internal/network/StaticNodeFinder.java:
##########
@@ -84,47 +112,53 @@ public void start() {
// No-op
}
- private static String[] resolveAll(String host) {
- InetAddress[] inetAddresses = null;
+ private List<NetworkAddress> resolveAddress(NetworkAddress address) {
+ InetAddress[] inetAddresses = resolveInetAddresses(address.host());
- int tryCount = 0;
- boolean resolved = false;
+ if (inetAddresses.length == 0) {
+ return List.of();
+ }
- do {
- tryCount++;
+ var addresses = new ArrayList<NetworkAddress>(inetAddresses.length);
- try {
- inetAddresses = InetAddress.getAllByName(host);
- resolved = true;
- } catch (UnknownHostException e) {
- if (tryCount == MAX_TRIES) {
- LOG.warn("Cannot resolve {}", host);
- return ArrayUtils.STRING_EMPTY_ARRAY;
- }
+ for (InetAddress inetAddress : inetAddresses) {
+ if (inetAddress.isLoopbackAddress()) {
+ // If it's a loopback address (like 127.0.0.1), only return
this address.
+ return List.of(new
NetworkAddress(inetAddress.getHostAddress(), address.port()));
+ }
+
+ addresses.add(new NetworkAddress(inetAddress.getHostAddress(),
address.port()));
+ }
+
+ return addresses;
+ }
+
+ private InetAddress[] resolveInetAddresses(String host) {
+ try {
+ int tryCount = 1;
+ while (true) {
try {
- Thread.sleep(tryCount * RETRY_WAIT_BASE_MILLIS);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
+ return hostNameResolver.getAllByName(host);
Review Comment:
I see, so it adds the address to cache, but then removes if got an exception
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]