xiaochen-zhou commented on code in PR #8311:
URL: https://github.com/apache/seatunnel/pull/8311#discussion_r1889646450
##########
seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/rest/RestService.java:
##########
@@ -298,16 +283,33 @@ public static List<PartitionDefinition> findPartitions(
}
logger.debug("Query SQL Sending to Doris FE is: '{}'.", sql);
- HttpPost httpPost =
- new HttpPost(getUriStr(dorisSourceConfig, dorisSourceTable,
logger) + QUERY_PLAN);
String entity = "{\"sql\": \"" + sql + "\"}";
logger.debug("Post body Sending to Doris FE is: '{}'.", entity);
StringEntity stringEntity = new StringEntity(entity,
StandardCharsets.UTF_8);
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
- httpPost.setEntity(stringEntity);
- String resStr = send(dorisSourceConfig, httpPost, logger);
+ List<String> feNodes =
Arrays.asList(dorisSourceConfig.getFrontends().split(","));
+ Collections.shuffle(feNodes);
+ int feNodesNum = feNodes.size();
+ String resStr = null;
+
+ for (int i = 0; i < feNodesNum; i++) {
+ try {
+ HttpPost httpPost =
+ new HttpPost(
+ getUriStr(feNodes.get(i), dorisSourceTable,
logger) + QUERY_PLAN);
+ httpPost.setEntity(stringEntity);
+ resStr = send(dorisSourceConfig, httpPost, logger);
+ break;
+ } catch (DorisConnectorException e) {
+ if (i == feNodesNum - 1) {
+ throw new DorisConnectorException(
+ DorisConnectorErrorCode.REST_SERVICE_FAILED, e);
+ }
+ }
Review Comment:
> Can we sure the exception is must cause by FE unavailable?
I updated the code to catch other potential exceptions.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]