This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 0160b65d67b Pipe: make exception message more friendly when creating
data sync pipe failed (#14208)
0160b65d67b is described below
commit 0160b65d67b8af3a2a77373de33fcc7c6e1e51d6
Author: nanxiang xia <[email protected]>
AuthorDate: Wed Nov 27 00:08:06 2024 +0800
Pipe: make exception message more friendly when creating data sync pipe
failed (#14208)
Co-authored-by: Steve Yurong Su <[email protected]>
---
.../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 6751216db89..1cf5c354d08 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;
@@ -124,12 +125,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) {
@@ -164,6 +180,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,
@@ -210,6 +227,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());
@@ -225,6 +243,7 @@ public abstract class IoTDBSyncClientManager extends
IoTDBClientManager implemen
client.getPort(),
e.getMessage(),
e);
+ endPoint2HandshakeErrorMessage.put(client.getEndPoint(), e.getMessage());
}
}