Skip to content

Commit d858c54

Browse files
authored
Merge pull request #538 from tapdata/TAP-6786
Tap 6786
2 parents 98ced90 + c27c965 commit d858c54

File tree

1 file changed

+16
-2
lines changed
  • connectors/doris-connector/src/main/java/io/tapdata/connector/doris

1 file changed

+16
-2
lines changed

connectors/doris-connector/src/main/java/io/tapdata/connector/doris/DorisTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import java.util.ArrayList;
2020
import java.util.Arrays;
2121
import java.util.List;
22+
import java.util.concurrent.atomic.AtomicBoolean;
2223
import java.util.concurrent.atomic.AtomicInteger;
24+
import java.util.concurrent.atomic.AtomicReference;
2325
import java.util.function.Consumer;
2426

2527
import static io.tapdata.base.ConnectorBase.testItem;
@@ -64,19 +66,31 @@ protected Boolean testVersion() {
6466
protected Boolean testWritePrivilege() {
6567
try {
6668
AtomicInteger beCount = new AtomicInteger(0);
69+
AtomicReference<String> invalidBeHost = new AtomicReference<>();
70+
AtomicReference<Integer> invalidHttpPort = new AtomicReference<>();
71+
AtomicReference<IOException> throwable = new AtomicReference<>();
6772
try {
6873
jdbcContext.normalQuery("show backends", resultSet -> {
74+
boolean hasValidNode = false;
6975
while (resultSet.next()) {
7076
beCount.incrementAndGet();
7177
String beHost = (resultSet.getString("Host"));
7278
Integer httpPort = (resultSet.getInt("HttpPort"));
7379
if (null == beHost || null == httpPort) continue;
7480
try {
75-
NetUtil.validateHostPortWithSocket(beHost, httpPort);
81+
if (!hasValidNode) {
82+
NetUtil.validateHostPortWithSocket(beHost, httpPort);
83+
hasValidNode = true;
84+
}
7685
} catch (IOException e) {
77-
throw new TapTestHostPortEx(e, beHost, String.valueOf(httpPort));
86+
invalidBeHost.set(beHost);
87+
invalidHttpPort.set(httpPort);
88+
throwable.set(e);
7889
}
7990
}
91+
if (!hasValidNode && null != throwable.get()) {
92+
throw new TapTestHostPortEx(throwable.get(), invalidBeHost.get(), String.valueOf(invalidHttpPort.get()));
93+
}
8094
});
8195
} catch (SQLSyntaxErrorException e) {
8296
if ("42000".equals(e.getSQLState())) {

0 commit comments

Comments
 (0)