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/01/24 13:35:51 UTC

[GitHub] [incubator-inlong] luchunliang opened a new pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

luchunliang opened a new pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327


   ### Title Name: [INLONG-2326][Inlong-SortStandalone] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.
   
   Fixes #2326 
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve.*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792291863



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSink.java
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.flume.Context;
+import org.apache.flume.EventDeliveryException;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.sink.AbstractSink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * EsSink
+ */
+public class EsSink extends AbstractSink implements Configurable {
+
+    public static final Logger LOG = LoggerFactory.getLogger(EsSink.class);
+
+    private Context parentContext;
+    private final LinkedBlockingQueue<EsIndexRequest> dispatchQueue = new LinkedBlockingQueue<>();
+    private EsSinkContext context;
+    // workers
+    private List<EsChannelWorker> workers = new ArrayList<>();
+    // output
+    private EsOutputChannel outputChannel;
+
+    /**
+     * start
+     */
+    @Override
+    public void start() {
+        super.start();
+        try {
+            this.context = new EsSinkContext(getName(), parentContext, getChannel(), dispatchQueue);
+            if (getChannel() == null) {
+                LOG.error("channel is null");

Review comment:
       since channel is null,  the init of EsSinkContext should be failed too. Maybe there should be restart process when channel is null until essink got correct channel




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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792320929



##########
File path: inlong-sort-standalone/sort-standalone-source/src/test/java/org/apache/inlong/sort/standalone/sink/elasticsearch/TestDefaultEvent2IndexRequestHandler.java
##########
@@ -0,0 +1,53 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * 
+ * TestDefaultEvent2IndexRequestHandler
+ */
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore("javax.management.*")
+public class TestDefaultEvent2IndexRequestHandler {
+
+    /**
+     * test
+     */
+    @Test
+    public void test() {

Review comment:
       need to specify the details of this test case




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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792291863



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSink.java
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.flume.Context;
+import org.apache.flume.EventDeliveryException;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.sink.AbstractSink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * EsSink
+ */
+public class EsSink extends AbstractSink implements Configurable {
+
+    public static final Logger LOG = LoggerFactory.getLogger(EsSink.class);
+
+    private Context parentContext;
+    private final LinkedBlockingQueue<EsIndexRequest> dispatchQueue = new LinkedBlockingQueue<>();
+    private EsSinkContext context;
+    // workers
+    private List<EsChannelWorker> workers = new ArrayList<>();
+    // output
+    private EsOutputChannel outputChannel;
+
+    /**
+     * start
+     */
+    @Override
+    public void start() {
+        super.start();
+        try {
+            this.context = new EsSinkContext(getName(), parentContext, getChannel(), dispatchQueue);
+            if (getChannel() == null) {
+                LOG.error("channel is null");

Review comment:
       since channel is null,  the init of EsSinkContext should be faied too. Maybe there should be restart when channel is null until essink got correct channel




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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r793197925



##########
File path: inlong-sort-standalone/sort-standalone-source/src/test/java/org/apache/inlong/sort/standalone/sink/elasticsearch/TestDefaultEvent2IndexRequestHandler.java
##########
@@ -0,0 +1,53 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * 
+ * TestDefaultEvent2IndexRequestHandler
+ */
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore("javax.management.*")
+public class TestDefaultEvent2IndexRequestHandler {
+
+    /**
+     * test
+     */
+    @Test
+    public void test() {

Review comment:
       add detail




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



[GitHub] [incubator-inlong] codecov-commenter commented on pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#issuecomment-1022784027


   # [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2327](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7c6222d) into [master](https://codecov.io/gh/apache/incubator-inlong/commit/2f37fb8a0effdff2450fc47b072f4602b50c6f52?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2f37fb8) will **increase** coverage by `0.00%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-inlong/pull/2327/graphs/tree.svg?width=650&height=150&src=pr&token=1EUK92O9K2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #2327   +/-   ##
   =========================================
     Coverage     12.53%   12.54%           
   - Complexity     1216     1217    +1     
   =========================================
     Files           420      420           
     Lines         36240    36240           
     Branches       5670     5670           
   =========================================
   + Hits           4543     4545    +2     
   + Misses        30891    30886    -5     
   - Partials        806      809    +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../inlong/tubemq/corebase/policies/FlowCtrlItem.java](https://codecov.io/gh/apache/incubator-inlong/pull/2327/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybEl0ZW0uamF2YQ==) | `38.88% <0.00%> (-1.12%)` | :arrow_down: |
   | [.../tubemq/corebase/policies/FlowCtrlRuleHandler.java](https://codecov.io/gh/apache/incubator-inlong/pull/2327/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybFJ1bGVIYW5kbGVyLmphdmE=) | `34.07% <0.00%> (-0.45%)` | :arrow_down: |
   | [...ong/tubemq/manager/service/ClusterServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2327/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvQ2x1c3RlclNlcnZpY2VJbXBsLmphdmE=) | `52.94% <0.00%> (+2.94%)` | :arrow_up: |
   | [...inlong/tubemq/manager/service/TaskServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2327/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvVGFza1NlcnZpY2VJbXBsLmphdmE=) | `8.53% <0.00%> (+4.87%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2f37fb8...7c6222d](https://codecov.io/gh/apache/incubator-inlong/pull/2327?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792284478



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);
+    }
+
+    /**
+     * afterBulk
+     * 
+     * @param executionId
+     * @param request
+     * @param response
+     */
+    @Override
+    public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
+//      LOG.info("afterBulk,executionId:" + executionId + ",request:" + request + ",response:" + response);
+        BulkItemResponse[] itemResponses = response.getItems();
+        List<DocWriteRequest<?>> requests = request.requests();
+        int itemSize = Math.min(itemResponses.length, requests.size());
+        if (itemResponses.length != requests.size()) {

Review comment:
       item size can be assigned to one of itemResponses.length  or requests.size() in the case that them are the same value. The comparison of Math.min is only need to operate in the unequal case




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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792276673



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);

Review comment:
       ditto




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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792276524



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);
+    }
+
+    /**
+     * afterBulk
+     * 
+     * @param executionId
+     * @param request
+     * @param response
+     */
+    @Override
+    public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
+//      LOG.info("afterBulk,executionId:" + executionId + ",request:" + request + ",response:" + response);

Review comment:
       remove commented code or use LOG.debug




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



[GitHub] [incubator-inlong] dockerzhang merged pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327


   


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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r793197094



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);
+    }
+
+    /**
+     * afterBulk
+     * 
+     * @param executionId
+     * @param request
+     * @param response
+     */
+    @Override
+    public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
+//      LOG.info("afterBulk,executionId:" + executionId + ",request:" + request + ",response:" + response);

Review comment:
       LOG.debug

##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);

Review comment:
       LOG.debug




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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r793197547



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSink.java
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.flume.Context;
+import org.apache.flume.EventDeliveryException;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.sink.AbstractSink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 

Review comment:
       delete empty line




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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r792288042



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSink.java
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.flume.Context;
+import org.apache.flume.EventDeliveryException;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.sink.AbstractSink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 

Review comment:
       empty line




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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r793197413



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsCallbackListener.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.List;
+
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.slf4j.Logger;
+
+/**
+ * EsCallbackListener
+ *
+ */
+public class EsCallbackListener implements BulkProcessor.Listener {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(EsCallbackListener.class);
+
+    private EsSinkContext context;
+
+    /**
+     * Constructor
+     * 
+     * @param context
+     */
+    public EsCallbackListener(EsSinkContext context) {
+        this.context = context;
+    }
+
+    /**
+     * beforeBulk
+     * 
+     * @param executionId
+     * @param request
+     */
+    @Override
+    public void beforeBulk(long executionId, BulkRequest request) {
+//      LOG.info("beforeBulk,executionId:" + executionId + ",request:" + request);
+    }
+
+    /**
+     * afterBulk
+     * 
+     * @param executionId
+     * @param request
+     * @param response
+     */
+    @Override
+    public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
+//      LOG.info("afterBulk,executionId:" + executionId + ",request:" + request + ",response:" + response);
+        BulkItemResponse[] itemResponses = response.getItems();
+        List<DocWriteRequest<?>> requests = request.requests();
+        int itemSize = Math.min(itemResponses.length, requests.size());
+        if (itemResponses.length != requests.size()) {

Review comment:
       use itemResponses.length




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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2327: [INLONG-2326] Inlong-Sort-Standalone support to sort the events to ElasticSearch cluster.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2327:
URL: https://github.com/apache/incubator-inlong/pull/2327#discussion_r793198453



##########
File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSink.java
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.inlong.sort.standalone.sink.elasticsearch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.flume.Context;
+import org.apache.flume.EventDeliveryException;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.sink.AbstractSink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * EsSink
+ */
+public class EsSink extends AbstractSink implements Configurable {
+
+    public static final Logger LOG = LoggerFactory.getLogger(EsSink.class);
+
+    private Context parentContext;
+    private final LinkedBlockingQueue<EsIndexRequest> dispatchQueue = new LinkedBlockingQueue<>();
+    private EsSinkContext context;
+    // workers
+    private List<EsChannelWorker> workers = new ArrayList<>();
+    // output
+    private EsOutputChannel outputChannel;
+
+    /**
+     * start
+     */
+    @Override
+    public void start() {
+        super.start();
+        try {
+            this.context = new EsSinkContext(getName(), parentContext, getChannel(), dispatchQueue);
+            if (getChannel() == null) {
+                LOG.error("channel is null");

Review comment:
       remove “getChannel() == null”.
   Can not restart a node because of a sort task.




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