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

[GitHub] [rocketmq-connect] Oliverwqcwrw opened a new pull request, #374: [ISSUE #373] Add elasticsearch sink connector

Oliverwqcwrw opened a new pull request, #374:
URL: https://github.com/apache/rocketmq-connect/pull/374

   ## What is the purpose of the change
   
   Close #373 
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq-connect/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


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

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


[GitHub] [rocketmq-connect] odbozhou merged pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
odbozhou merged PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374


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

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


[GitHub] [rocketmq-connect] Ceilzcx commented on pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Ceilzcx commented on PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#issuecomment-1318229818

   hi, Whether it is necessary to add username and password in org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig?


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

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


[GitHub] [rocketmq-connect] odbozhou commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
odbozhou commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1022370794


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkConnector.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.Task;
+import io.openmessaging.connector.api.component.task.sink.SinkConnector;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+
+public class ElasticsearchSinkConnector extends SinkConnector {
+
+    private KeyValue config;
+
+    @Override
+    public void validate(KeyValue config) {
+        for (String requestKey : ElasticsearchConfig.REQUEST_CONFIG_SINK) {
+            if (!config.containsKey(requestKey)) {
+                throw new RuntimeException("Request config key: " + requestKey);
+            }
+        }
+    }
+
+    @Override
+    public List<KeyValue> taskConfigs(int maxTasks) {
+        List<KeyValue> configs = new ArrayList<>();

Review Comment:
   Multiple taskconfigs can be created according to maxtasks to give full play to the ability of multi-threaded data synchronization



##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkTask.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.sink.SinkTask;
+import io.openmessaging.connector.api.data.ConnectRecord;
+import io.openmessaging.connector.api.errors.ConnectException;
+import java.io.IOException;
+import java.util.List;
+import org.apache.http.HttpHost;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConstant;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.client.Node;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ElasticsearchSinkTask extends SinkTask {
+
+    private static final Logger log = LoggerFactory.getLogger(ElasticsearchSinkTask.class);
+
+    private ElasticsearchConfig config;
+
+    private RestHighLevelClient restHighLevelClient;
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) throws ConnectException {
+        if (sinkRecords == null || sinkRecords.size() < 1) {
+            return;
+        }
+        for (ConnectRecord record : sinkRecords) {
+            final String indexName = record.getExtension(ElasticsearchConstant.INDEX);

Review Comment:
   Is it possible to get the indexname based on the topic name?



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

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1021480274


##########
connectors/rocketmq-connect-elasticsearch/pom.xml:
##########
@@ -223,7 +223,7 @@
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-high-level-client</artifactId>
-            <version>7.6.2</version>
+            <version>7.14.0</version>

Review Comment:
   The 8.x version of es supports at least jdk17, so we won't upgrade to 8.x yet



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

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1021455926


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkTask.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.sink.SinkTask;
+import io.openmessaging.connector.api.data.ConnectRecord;
+import io.openmessaging.connector.api.errors.ConnectException;
+import java.io.IOException;
+import java.util.List;
+import org.apache.http.HttpHost;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConstant;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.client.Node;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.xcontent.XContentType;
+
+public class ElasticsearchSinkTask extends SinkTask {
+
+    private ElasticsearchConfig config;
+
+    private RestHighLevelClient restHighLevelClient;
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) throws ConnectException {
+        if (sinkRecords == null || sinkRecords.size() < 1) {
+            return;
+        }
+        for (ConnectRecord record : sinkRecords) {
+            final String indexName = record.getExtension(ElasticsearchConstant.INDEX);
+            if (indexName == null || indexName == "") {
+                continue;
+            }
+            final String data = record.getData().toString();
+            IndexRequest indexRequest = new IndexRequest(indexName);
+            indexRequest.source(data, XContentType.JSON);
+            try {
+                restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }

Review Comment:
   Thanks for your remind, 
   It should not terminate the entire task,
   I will optimize it



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

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1026195817


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkTask.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.sink.SinkTask;
+import io.openmessaging.connector.api.data.ConnectRecord;
+import io.openmessaging.connector.api.errors.ConnectException;
+import java.io.IOException;
+import java.util.List;
+import org.apache.http.HttpHost;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConstant;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.client.Node;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ElasticsearchSinkTask extends SinkTask {
+
+    private static final Logger log = LoggerFactory.getLogger(ElasticsearchSinkTask.class);
+
+    private ElasticsearchConfig config;
+
+    private RestHighLevelClient restHighLevelClient;
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) throws ConnectException {
+        if (sinkRecords == null || sinkRecords.size() < 1) {
+            return;
+        }
+        for (ConnectRecord record : sinkRecords) {
+            final String indexName = record.getExtension(ElasticsearchConstant.INDEX);

Review Comment:
   Is it better to keep the index name the same as the index name of the data source?



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

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1026194854


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkConnector.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.Task;
+import io.openmessaging.connector.api.component.task.sink.SinkConnector;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+
+public class ElasticsearchSinkConnector extends SinkConnector {
+
+    private KeyValue config;
+
+    @Override
+    public void validate(KeyValue config) {
+        for (String requestKey : ElasticsearchConfig.REQUEST_CONFIG_SINK) {
+            if (!config.containsKey(requestKey)) {
+                throw new RuntimeException("Request config key: " + requestKey);
+            }
+        }
+    }
+
+    @Override
+    public List<KeyValue> taskConfigs(int maxTasks) {
+        List<KeyValue> configs = new ArrayList<>();

Review Comment:
   ok, I will optimize it



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

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1021457455


##########
connectors/rocketmq-connect-elasticsearch/pom.xml:
##########
@@ -223,7 +223,7 @@
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-high-level-client</artifactId>
-            <version>7.6.2</version>
+            <version>7.14.0</version>

Review Comment:
   I will try to upgrade the version to 8.x to see if there are any conflicts



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

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


[GitHub] [rocketmq-connect] caigy commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
caigy commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1021123541


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkTask.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.sink.SinkTask;
+import io.openmessaging.connector.api.data.ConnectRecord;
+import io.openmessaging.connector.api.errors.ConnectException;
+import java.io.IOException;
+import java.util.List;
+import org.apache.http.HttpHost;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConstant;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.client.Node;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.xcontent.XContentType;
+
+public class ElasticsearchSinkTask extends SinkTask {
+
+    private ElasticsearchConfig config;
+
+    private RestHighLevelClient restHighLevelClient;
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) throws ConnectException {
+        if (sinkRecords == null || sinkRecords.size() < 1) {
+            return;
+        }
+        for (ConnectRecord record : sinkRecords) {
+            final String indexName = record.getExtension(ElasticsearchConstant.INDEX);
+            if (indexName == null || indexName == "") {
+                continue;
+            }
+            final String data = record.getData().toString();
+            IndexRequest indexRequest = new IndexRequest(indexName);
+            indexRequest.source(data, XContentType.JSON);
+            try {
+                restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }

Review Comment:
   Does `IOException` terminate the whole pipeline?



##########
connectors/rocketmq-connect-elasticsearch/pom.xml:
##########
@@ -223,7 +223,7 @@
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-high-level-client</artifactId>
-            <version>7.6.2</version>
+            <version>7.14.0</version>

Review Comment:
   Is ES 8.x supported?



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

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


[GitHub] [rocketmq-connect] odbozhou commented on a diff in pull request #374: [ISSUE #373] Add elasticsearch sink connector

Posted by GitBox <gi...@apache.org>.
odbozhou commented on code in PR #374:
URL: https://github.com/apache/rocketmq-connect/pull/374#discussion_r1030163961


##########
connectors/rocketmq-connect-elasticsearch/src/main/java/org/apache/rocketmq/connect/elasticsearch/connector/ElasticsearchSinkTask.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.connect.elasticsearch.connector;
+
+import com.alibaba.fastjson.JSONObject;
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.sink.SinkTask;
+import io.openmessaging.connector.api.data.ConnectRecord;
+import io.openmessaging.connector.api.data.Field;
+import io.openmessaging.connector.api.data.FieldType;
+import io.openmessaging.connector.api.data.Struct;
+import io.openmessaging.connector.api.errors.ConnectException;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConfig;
+import org.apache.rocketmq.connect.elasticsearch.config.ElasticsearchConstant;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.client.Node;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.GetMappingsRequest;
+import org.elasticsearch.client.indices.GetMappingsResponse;
+import org.elasticsearch.client.indices.PutMappingRequest;
+import org.elasticsearch.cluster.metadata.MappingMetadata;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ElasticsearchSinkTask extends SinkTask {
+
+    private static final Logger log = LoggerFactory.getLogger(ElasticsearchSinkTask.class);
+
+    private ElasticsearchConfig config;
+
+    private RestHighLevelClient restHighLevelClient;
+
+    private Set<String> indexCache;
+
+    private Map<String, Boolean> mappingCache;
+
+    private static final String PROPERTIES_FIELD = "properties";
+
+    private static final String TYPE_FIELD = "type";
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) throws ConnectException {
+        if (sinkRecords == null || sinkRecords.size() < 1) {
+            return;
+        }
+        for (ConnectRecord record : sinkRecords) {
+            String indexName = record.getExtension(ElasticsearchConstant.INDEX);

Review Comment:
   Is it possible to get the index name through the topic name if there is no index name in the extended information
   ![image](https://user-images.githubusercontent.com/14222167/203504355-e15917d2-f2a8-4ab6-8d86-700cbd32b0f0.png)
   



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

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