You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "vernedeng (via GitHub)" <gi...@apache.org> on 2023/02/13 02:48:08 UTC

[GitHub] [inlong] vernedeng commented on a diff in pull request #7348: [INLONG-7337][Manager] Fix test Pulsar connection error

vernedeng commented on code in PR #7348:
URL: https://github.com/apache/inlong/pull/7348#discussion_r1103947349


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/PulsarClusterOperator.java:
##########
@@ -110,19 +112,34 @@ public Boolean testConnection(ClusterRequest request) {
                     String.format("Pulsar ServiceUrl=%s should starts with %s", serviceUrl, SERVICE_URL_PREFIX));
 
             String hostPortStr = serviceUrl.replaceAll(SERVICE_URL_PREFIX, "");
-            String[] hostPortArr = hostPortStr.split(InlongConstants.COLON);
-            Preconditions.expectTrue(hostPortArr.length >= 2,
-                    String.format("Pulsar ServiceUrl=%s should has ip and port, such as '127.0.0.1:6650'", serviceUrl));
-
-            String host = hostPortArr[0];
-            int port = Integer.parseInt(hostPortArr[1]);
-            SocketAddress socketAddress = new InetSocketAddress(host, port);
-            Socket socket = new Socket();
-            socket.connect(socketAddress, 30000);
-            socket.close();
-            LOGGER.debug("Pulsar connection not null - connection success for AdminUrl={}, ServiceUrl={}",
-                    pulsarInfo.getAdminUrl(), pulsarInfo.getUrl());
-            return true;
+            boolean successConnect = Arrays.stream(hostPortStr.split(InlongConstants.COMMA))
+                    // If there are multiple addresses, as long as one succeeds, it's considered successful
+                    .anyMatch(hostPort -> {

Review Comment:
   I think it is considered successful only when all addressses are available.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org