You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/15 15:29:06 UTC

[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #3108: [Feature][Connector-V2-Clickhouse] Clickhouse Source random use host when config multi-host

hailin0 commented on code in PR #3108:
URL: https://github.com/apache/incubator-seatunnel/pull/3108#discussion_r996320201


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSource.java:
##########
@@ -71,9 +72,10 @@ public void prepare(Config config) throws PrepareFailException {
                 config.getString(USERNAME), config.getString(PASSWORD));
 
         sql = config.getString(SQL);
-        try (ClickHouseClient client = ClickHouseClient.newInstance(servers.get(0).getProtocol());
+        ClickHouseNode currentServer = servers.get(threadLocalRandom.nextInt(servers.size()));

Review Comment:
   ```suggestion
           ClickHouseNode currentServer = servers.get(ThreadLocalRandom.current().nextInt(servers.size()));
   ```



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSource.java:
##########
@@ -55,6 +55,7 @@ public class ClickhouseSource implements SeaTunnelSource<SeaTunnelRow, Clickhous
     private List<ClickHouseNode> servers;
     private SeaTunnelRowType rowTypeInfo;
     private String sql;
+    private final ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();

Review Comment:
   call directly inside the method



-- 
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@seatunnel.apache.org

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