rpuch commented on code in PR #7188:
URL: https://github.com/apache/ignite-3/pull/7188#discussion_r2602012752
##########
modules/network/src/main/java/org/apache/ignite/internal/network/StaticNodeFinder.java:
##########
@@ -70,14 +84,33 @@ public void start() {
}
private static String[] resolveAll(String host) {
- InetAddress[] inetAddresses;
- try {
- inetAddresses = InetAddress.getAllByName(host);
- } catch (UnknownHostException e) {
- LOG.warn("Cannot resolve {}", host);
- return ArrayUtils.STRING_EMPTY_ARRAY;
- }
+ InetAddress[] inetAddresses = null;
+
+ final int maxTries = 3;
+ int tryCount = 0;
+ boolean resolved = false;
+
+ do {
+ tryCount++;
+
+ try {
+ inetAddresses = InetAddress.getAllByName(host);
+ resolved = true;
+ } catch (UnknownHostException e) {
+ if (tryCount == maxTries) {
+ LOG.warn("Cannot resolve {}", host);
+ return ArrayUtils.STRING_EMPTY_ARRAY;
+ }
+
+ try {
+ Thread.sleep(tryCount * 500L);
+ } catch (InterruptedException ex) {
+ throw new IgniteInternalException(INTERNAL_ERR, ex);
Review Comment:
1. Let's restore the thread interruption status first
(`Thread.currentThread().interrupt()`)
2. Let's not rethrow and just return the empty result as if we were out of
retries
##########
modules/network/src/main/java/org/apache/ignite/internal/network/StaticNodeFinder.java:
##########
@@ -70,14 +84,33 @@ public void start() {
}
private static String[] resolveAll(String host) {
- InetAddress[] inetAddresses;
- try {
- inetAddresses = InetAddress.getAllByName(host);
- } catch (UnknownHostException e) {
- LOG.warn("Cannot resolve {}", host);
- return ArrayUtils.STRING_EMPTY_ARRAY;
- }
+ InetAddress[] inetAddresses = null;
+
+ final int maxTries = 3;
+ int tryCount = 0;
+ boolean resolved = false;
+
+ do {
+ tryCount++;
+
+ try {
+ inetAddresses = InetAddress.getAllByName(host);
+ resolved = true;
+ } catch (UnknownHostException e) {
+ if (tryCount == maxTries) {
+ LOG.warn("Cannot resolve {}", host);
+ return ArrayUtils.STRING_EMPTY_ARRAY;
+ }
+
+ try {
+ Thread.sleep(tryCount * 500L);
Review Comment:
1. Let's introduce a constant for 500
2. Why does the wait time increase on each iteration?
##########
modules/api/src/main/java/org/apache/ignite/network/NetworkAddress.java:
##########
@@ -41,6 +41,14 @@ public class NetworkAddress {
* @param port Port.
*/
public NetworkAddress(String host, int port) {
+ if (host == null || host.isEmpty()) {
+ throw new IllegalArgumentException("Host address cannot be null or
empty");
+ }
+
+ if (port < 1024 || port > 65535) {
Review Comment:
Why do we forbid the usage of ports less than 1024?
##########
modules/network/src/main/java/org/apache/ignite/internal/network/StaticNodeFinder.java:
##########
@@ -70,14 +84,33 @@ public void start() {
}
private static String[] resolveAll(String host) {
- InetAddress[] inetAddresses;
- try {
- inetAddresses = InetAddress.getAllByName(host);
- } catch (UnknownHostException e) {
- LOG.warn("Cannot resolve {}", host);
- return ArrayUtils.STRING_EMPTY_ARRAY;
- }
+ InetAddress[] inetAddresses = null;
+
+ final int maxTries = 3;
+ int tryCount = 0;
+ boolean resolved = false;
+
+ do {
+ tryCount++;
+
+ try {
+ inetAddresses = InetAddress.getAllByName(host);
+ resolved = true;
+ } catch (UnknownHostException e) {
+ if (tryCount == maxTries) {
Review Comment:
```suggestion
if (tryCount == maxTries) {
```
--
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]