You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/05/07 12:20:09 UTC

[GitHub] [incubator-seatunnel] lonelyGhostisdog opened a new pull request, #1821: Seatunnel 1802

lonelyGhostisdog opened a new pull request, #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   add kafka batch sink [#1802](https://github.com/apache/incubator-seatunnel/issues/1802)
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123327177

   > 
   
   Flink native has been unified, but datastream and dataset are still distinguished in Seatunnel.
   For example, if I want to read HDFS files and write kafka, I cannot use Seatunnel to do so until I commit the PR because Seatunnel send dataset form source, not datastream
   


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1120736506

   All checks have passed, Who can help me review the code ? Thanks for every one


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

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


[GitHub] [incubator-seatunnel] wuchunfu commented on pull request #1821: Seatunnel 1802

Posted by GitBox <gi...@apache.org>.
wuchunfu commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1120211327

   @lonelyGhostisdog Please modify the pr title, thanks.


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123327659

   > > 
   > 
   > Flink native has been unified, but datastream and dataset are still distinguished in Seatunnel. For example, if I want to read HDFS files and write kafka, I cannot use Seatunnel to do so until I commit the PR because Seatunnel send dataset form source, not datastream
   
   reply for @leo65535 


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

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


[GitHub] [incubator-seatunnel] leo65535 commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
leo65535 commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123298885

   Thanks @lonelyGhostisdog, flink already unfiy the `streaming` and `batch` semantics, by using `EnvironmentSettings.newInstance().inStreamingMode();`, we don't need write two type connecters(for streaming, for batch).
   Maybe I can't understand what is `kafka batch sink`?
   


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

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


[GitHub] [incubator-seatunnel] wuchunfu commented on a diff in pull request #1821: Seatunnel 1802

Posted by GitBox <gi...@apache.org>.
wuchunfu commented on code in PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#discussion_r867353665


##########
seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/kafka/FakeSourceToKafkaIT.java:
##########
@@ -0,0 +1,124 @@
+package org.apache.seatunnel.e2e.flink.kafka;
+

Review Comment:
   @lonelyGhostisdog  Please add license header, thanks.



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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123147847

   @ruanwenjun  thanks for your reivew, i will fix then soon


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1120737011

   > All checks have passed, Who can help me review the code ? Thanks for every one
   
   @wuchunfu @ruanwenjun  Can help me reivew code?


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123248131

   @ruanwenjun Hi, Flink E2E test can be completed in my environment, so how should I solve the problems in CI? Or can you retrigger it for me?


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

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


[GitHub] [incubator-seatunnel] leo65535 commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
leo65535 commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123448454

   > > > 
   > > 
   > > 
   > > Flink native has been unified, but datastream and dataset are still distinguished in Seatunnel. For example, if I want to read HDFS files and write kafka, I cannot use Seatunnel to do so until I commit the PR because Seatunnel send dataset form source, not datastream
   > 
   > reply for @leo65535
   
   hi, we talk about this topic and want to remove the dataset api in seatunnel project https://github.com/apache/incubator-seatunnel/pull/1287, I worry that it will cause more complex if we continue add batch connectors.


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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on a diff in pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on code in PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#discussion_r867423727


##########
seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/kafka/FakeSourceToKafkaIT.java:
##########
@@ -0,0 +1,124 @@
+package org.apache.seatunnel.e2e.flink.kafka;
+

Review Comment:
   Done



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

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


[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#discussion_r869805308


##########
seatunnel-common/src/main/java/org/apache/seatunnel/common/MapUtil.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.seatunnel.common;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapUtil {
+    private MapUtil() {
+
+    }
+
+    public static Map<String, String> setMap(Config config, String prefix, boolean keepPrefix) {

Review Comment:
   There are already a util to do this `TypesafeConfigUtils#extractSubConfig`.



##########
seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/kafka/FakeSourceToKafkaIT.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * 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.seatunnel.e2e.flink.kafka;
+
+import org.apache.seatunnel.e2e.flink.FlinkContainer;
+
+import com.google.common.collect.Lists;
+import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.ByteArrayDeserializer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.lifecycle.Startables;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.stream.Stream;
+
+public class FakeSourceToKafkaIT extends FlinkContainer {
+    private static final String KAFKA_DOCKER_IMAGE = "bitnami/kafka:latest";
+    private static final String ZOOKEEPER_DOCKER_IMAGE = "bitnami/zookeeper:latest";
+    private static final Logger LOGGER = LoggerFactory.getLogger(FakeSourceToKafkaIT.class);
+    private GenericContainer<?> kafkaServer;
+    private GenericContainer<?> zookeeperServer;

Review Comment:
   It might be better to directly use [KafkaContainer](https://www.testcontainers.org/modules/kafka/).



##########
seatunnel-e2e/seatunnel-flink-e2e/src/test/resources/log4j.properties:
##########
@@ -16,7 +16,7 @@
 #
 
 # Set everything to be logged to the console
-log4j.rootCategory=ERROR, console
+log4j.rootCategory=INFO, console

Review Comment:
   It's better to revert this, I remember if we change to info level, it might output a lot of logs and might block the CI, I am not sure.



##########
docs/en/connector/sink/Kafka.md:
##########
@@ -22,6 +22,19 @@ Engine Supported and plugin name
 | producer.*                 | string | no       | -             |
 | semantic                   | string | no       | -             |
 | common-options             | string | no       | -             |
+------------------------------------------------------------------
+If you want to write data to kafka by batch job, some additional parameters for `format` need to be specified.
+
+| name                               | type   | required | default value |
+| ---------------------------------- | ------ | -------- | ------------- |
+| format.type                        | string | yes      | -             |
+| format.csv.field_delimiter         | string | no       | ,             |
+| format.csv.line_delimiter          | string | no       | \n            |
+| format.csv.disable_quote_character | string | no       | false         |
+| format.csv.quote_character         | string | no       | ''            |
+| format.csv.array_element_delimiter | string | no       | ;             |
+| format.csv.escape_character        | string | no       | -             |
+| format.csv.null_literal            | string | no       | -             |

Review Comment:
   It's better to add an example of this batch config.



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

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


[GitHub] [incubator-seatunnel] lonelyGhostisdog commented on pull request #1821: [Feature][flink-connector-kafka] add kafka batch sink #1802

Posted by GitBox <gi...@apache.org>.
lonelyGhostisdog commented on PR #1821:
URL: https://github.com/apache/incubator-seatunnel/pull/1821#issuecomment-1123577511

   > > > > 
   > > > 
   > > > 
   > > > Flink native has been unified, but datastream and dataset are still distinguished in Seatunnel. For example, if I want to read HDFS files and write kafka, I cannot use Seatunnel to do so until I commit the PR because Seatunnel send dataset form source, not datastream
   > > 
   > > 
   > > reply for @leo65535
   > 
   > hi, we talk about this topic and want to remove the dataset api in seatunnel project #1287, I worry that it will cause more complex if we continue add batch connectors.
   
   Before this pr been merged, we also need to read data as batch mode and then write to kafka or other datasource


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

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