Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -122,12 +123,27 @@ public void checkClientStatusAndTryReconstructIfNecessary() {
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) {
Expand Down Expand Up @@ -162,6 +178,7 @@ private void initClientAndStatus(
trustStorePath,
trustStorePwd));
} catch (Exception e) {
endPoint2HandshakeErrorMessage.put(endPoint, e.getMessage());
throw new PipeConnectionException(
String.format(
PipeConnectionException.CONNECTION_ERROR_FORMATTER,
Expand Down Expand Up @@ -208,6 +225,7 @@ public void sendHandshakeReq(final Pair<IoTDBSyncClient, Boolean> clientAndStatu
client.getIpAddress(),
client.getPort(),
resp.getStatus());
endPoint2HandshakeErrorMessage.put(client.getEndPoint(), resp.getStatus().getMessage());
} else {
clientAndStatus.setRight(true);
client.setTimeout(CONNECTION_TIMEOUT_MS.get());
Expand All @@ -223,6 +241,7 @@ public void sendHandshakeReq(final Pair<IoTDBSyncClient, Boolean> clientAndStatu
client.getPort(),
e.getMessage(),
e);
endPoint2HandshakeErrorMessage.put(client.getEndPoint(), e.getMessage());
}
}

Expand Down