|
19 | 19 | import java.util.ArrayList; |
20 | 20 | import java.util.Arrays; |
21 | 21 | import java.util.List; |
| 22 | +import java.util.concurrent.atomic.AtomicBoolean; |
22 | 23 | import java.util.concurrent.atomic.AtomicInteger; |
| 24 | +import java.util.concurrent.atomic.AtomicReference; |
23 | 25 | import java.util.function.Consumer; |
24 | 26 |
|
25 | 27 | import static io.tapdata.base.ConnectorBase.testItem; |
@@ -64,19 +66,31 @@ protected Boolean testVersion() { |
64 | 66 | protected Boolean testWritePrivilege() { |
65 | 67 | try { |
66 | 68 | AtomicInteger beCount = new AtomicInteger(0); |
| 69 | + AtomicReference<String> invalidBeHost = new AtomicReference<>(); |
| 70 | + AtomicReference<Integer> invalidHttpPort = new AtomicReference<>(); |
| 71 | + AtomicReference<IOException> throwable = new AtomicReference<>(); |
67 | 72 | try { |
68 | 73 | jdbcContext.normalQuery("show backends", resultSet -> { |
| 74 | + boolean hasValidNode = false; |
69 | 75 | while (resultSet.next()) { |
70 | 76 | beCount.incrementAndGet(); |
71 | 77 | String beHost = (resultSet.getString("Host")); |
72 | 78 | Integer httpPort = (resultSet.getInt("HttpPort")); |
73 | 79 | if (null == beHost || null == httpPort) continue; |
74 | 80 | try { |
75 | | - NetUtil.validateHostPortWithSocket(beHost, httpPort); |
| 81 | + if (!hasValidNode) { |
| 82 | + NetUtil.validateHostPortWithSocket(beHost, httpPort); |
| 83 | + hasValidNode = true; |
| 84 | + } |
76 | 85 | } catch (IOException e) { |
77 | | - throw new TapTestHostPortEx(e, beHost, String.valueOf(httpPort)); |
| 86 | + invalidBeHost.set(beHost); |
| 87 | + invalidHttpPort.set(httpPort); |
| 88 | + throwable.set(e); |
78 | 89 | } |
79 | 90 | } |
| 91 | + if (!hasValidNode && null != throwable.get()) { |
| 92 | + throw new TapTestHostPortEx(throwable.get(), invalidBeHost.get(), String.valueOf(invalidHttpPort.get())); |
| 93 | + } |
80 | 94 | }); |
81 | 95 | } catch (SQLSyntaxErrorException e) { |
82 | 96 | if ("42000".equals(e.getSQLState())) { |
|
0 commit comments