exceptionfactory commented on code in PR #9168:
URL: https://github.com/apache/nifi/pull/9168#discussion_r1712223978


##########
nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java:
##########
@@ -296,6 +305,16 @@ private void processHeartbeat(final NodeHeartbeat 
heartbeat) {
         clusterCoordinator.validateHeartbeat(heartbeat);
     }
 
+    private boolean isNodeApiReachable(final NodeIdentifier nodeIdentifier) {
+        try {
+            final InetAddress nodeApiAddress = 
InetAddress.getByName(nodeIdentifier.getApiAddress());
+            return nodeApiAddress.isReachable((int) 
NODE_API_TIMEOUT.toMillis());

Review Comment:
   The 
[isReachable](https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#isReachable-int-)
 method can behave differently depending on the platform, sometimes using ICMP, 
and sometimes using TCP port 7. For a more reliable check, seems worth 
considering making a socket connection to the node port, which would ensure 
basic TCP connectivity.



##########
nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java:
##########
@@ -288,6 +292,11 @@ private void processHeartbeat(final NodeHeartbeat 
heartbeat) {
                 return;
             }
 
+            if (!isNodeApiReachable(nodeId)) {
+                logger.info("Received a connection request from {}, but the 
node's API address is not reachable, will not connect node to the cluster yet", 
nodeId);

Review Comment:
   What do you think about adjusting the wording?
   ```suggestion
                   logger.info("Node API Address [{}] not reachable: cluster 
connection request deferred pending successful network connection", nodeId);
   ```



-- 
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]

Reply via email to