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

[GitHub] [inlong] healchow commented on a diff in pull request #6660: [INLONG-6659][Manager] Using the elasticsearch data node when creating streamSink

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: commits-unsubscribe@inlong.apache.org

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