healchow commented on code in PR #6660:
URL: https://github.com/apache/inlong/pull/6660#discussion_r1034417987


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/es/ElasticsearchResourceOperator.java:
##########
@@ -138,4 +133,28 @@ public List<ElasticsearchFieldInfo> 
getElasticsearchFieldFromSink(List<StreamSin
         return esFieldList;
     }
 
+    private ElasticsearchConfig getElasticsearchConfig(SinkInfo sinkInfo, 
ElasticsearchSinkDTO esInfo) {
+        ElasticsearchConfig config = new ElasticsearchConfig();
+        if (StringUtils.isNotEmpty(esInfo.getUsername())) {
+            config.setAuthEnable(true);
+            config.setUsername(esInfo.getUsername());
+            config.setPassword(esInfo.getPassword());
+        }
+        config.setHost(esInfo.getHost());
+        config.setPort(esInfo.getPort());
+        // read from data node if not supplied by user
+        if (StringUtils.isBlank(esInfo.getHost())) {
+            ElasticsearchDataNodeInfo esDataNode = (ElasticsearchDataNodeInfo) 
dataNodeHelper.getDataNodeInfo(
+                    sinkInfo.getDataNodeName(), DataNodeType.ELASTICSEARCH);
+            String[] esUrl = esDataNode.getUrl().split(InlongConstants.COLON);
+            String esHost = esUrl[0];
+            int esPort = Integer.parseInt(esUrl[1]);

Review Comment:
   There may be an out-of-bounds exception.



-- 
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]

Reply via email to