You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2024/11/28 02:34:36 UTC

(iotdb) branch dev/1.3 updated: Pipe: make exception message more friendly when creating data sync pipe failed (#14208) (#14214)

This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new 36d93f17117 Pipe: make exception message more friendly when creating data sync pipe failed (#14208) (#14214)
36d93f17117 is described below

commit 36d93f171175a734a51322f22f24a3cf03edc42b
Author: nanxiang xia <16...@users.noreply.github.com>
AuthorDate: Thu Nov 28 10:34:31 2024 +0800

    Pipe: make exception message more friendly when creating data sync pipe failed (#14208) (#14214)
    
    Co-authored-by: Steve Yurong Su <ro...@apache.org>
---
 .../connector/client/IoTDBSyncClientManager.java   | 25 +++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java
index 022e4fc7b53..9ad0eedcf1d 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java
@@ -57,6 +57,7 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen
 
   protected final Map<TEndPoint, Pair<IoTDBSyncClient, Boolean>> endPoint2ClientAndStatus =
       new ConcurrentHashMap<>();
+  private final Map<TEndPoint, String> endPoint2HandshakeErrorMessage = new ConcurrentHashMap<>();
 
   private final LoadBalancer loadBalancer;
 
@@ -122,12 +123,27 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen
         return;
       }
     }
-    throw new PipeConnectionException(
-        String.format(
-            "All target servers %s are not available.", endPoint2ClientAndStatus.keySet()));
+    final StringBuilder errorMessage =
+        new StringBuilder(
+            String.format(
+                "All target servers %s are not available.", endPoint2ClientAndStatus.keySet()));
+    for (final Map.Entry<TEndPoint, String> entry : endPoint2HandshakeErrorMessage.entrySet()) {
+      errorMessage
+          .append(" (")
+          .append(" host: ")
+          .append(entry.getKey().getIp())
+          .append(", port: ")
+          .append(entry.getKey().getPort())
+          .append(", because: ")
+          .append(entry.getValue())
+          .append(")");
+    }
+    throw new PipeConnectionException(errorMessage.toString());
   }
 
   protected void reconstructClient(TEndPoint endPoint) {
+    endPoint2HandshakeErrorMessage.remove(endPoint);
+
     final Pair<IoTDBSyncClient, Boolean> clientAndStatus = endPoint2ClientAndStatus.get(endPoint);
 
     if (clientAndStatus.getLeft() != null) {
@@ -162,6 +178,7 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen
               trustStorePath,
               trustStorePwd));
     } catch (Exception e) {
+      endPoint2HandshakeErrorMessage.put(endPoint, e.getMessage());
       throw new PipeConnectionException(
           String.format(
               PipeConnectionException.CONNECTION_ERROR_FORMATTER,
@@ -208,6 +225,7 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen
             client.getIpAddress(),
             client.getPort(),
             resp.getStatus());
+        endPoint2HandshakeErrorMessage.put(client.getEndPoint(), resp.getStatus().getMessage());
       } else {
         clientAndStatus.setRight(true);
         client.setTimeout(CONNECTION_TIMEOUT_MS.get());
@@ -223,6 +241,7 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen
           client.getPort(),
           e.getMessage(),
           e);
+      endPoint2HandshakeErrorMessage.put(client.getEndPoint(), e.getMessage());
     }
   }