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/09/21 08:05:31 UTC

[GitHub] [incubator-seatunnel] Xuxiaotuan opened a new pull request, #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   <!--
   
   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
   
   Add new new connecotor of TiKV source and sink,
   refer to https://github.com/apache/incubator-seatunnel/issues/1946#issuecomment-1253260625.
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   ## Check list
   
   * [x] Code changed are covered with tests.
   * [ ] 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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   > And tell the user why implementing in Java client is better than JDBC, or the different between two way.
   
   sure 😃


-- 
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] Xuxiaotuan commented on a diff in pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

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


##########
seatunnel-connectors-v2/connector-tikv/src/main/java/org/apache/seatunnel/connectors/seatunnel/tikv/source/TiKVSource.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.connectors.seatunnel.tikv.source;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.serialization.Serializer;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.connectors.seatunnel.common.schema.SeaTunnelSchema;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitEnumeratorState;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVConfig;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVParameters;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(SeaTunnelSource.class)
+public class TiKVSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+
+    private final TiKVParameters tikvParameters = new TiKVParameters();
+
+    private SeaTunnelRowType seaTunnelRowType;
+
+    private DeserializationSchema<SeaTunnelRow> deserializationSchema;
+
+    @Override
+    public String getPluginName() {
+        return TiKVConfig.NAME;
+    }
+
+    /**
+     * init configuration parameters
+     *
+     * @param config plugin config.
+     * @throws PrepareFailException prepare failed
+     */
+    @Override
+    public void prepare(Config config) throws PrepareFailException {
+        CheckResult result = CheckConfigUtil.checkAllExists(config, TiKVConfig.HOST, TiKVConfig.DATA_TYPE, TiKVConfig.DATA_TYPE);
+        if (!result.isSuccess()) {
+            throw new PrepareFailException(getPluginName(), PluginType.SOURCE, result.getMsg());
+        }
+        // init tikv configuration
+        this.tikvParameters.initConfig(config);
+
+        // init seaTunnelRowType
+        if (config.hasPath(SeaTunnelSchema.SCHEMA)) {
+            Config schema = config.getConfig(SeaTunnelSchema.SCHEMA);
+            this.seaTunnelRowType = SeaTunnelSchema.buildWithConfig(schema).getSeaTunnelRowType();
+        } else {
+            this.seaTunnelRowType = SeaTunnelSchema.buildSimpleTextSchema();
+        }
+
+        if (config.hasPath(TiKVConfig.FORMAT)) {
+            this.deserializationSchema = null;
+        } else {
+            this.deserializationSchema = new JsonDeserializationSchema(false, false, seaTunnelRowType);
+        }
+    }
+
+    @Override
+    public Boundedness getBoundedness() {
+        return Boundedness.BOUNDED;
+    }
+
+    @Override
+    public SeaTunnelDataType<SeaTunnelRow> getProducedType() {
+        return seaTunnelRowType;
+    }
+
+    @Override
+    public AbstractSingleSplitReader<SeaTunnelRow> createReader(SingleSplitReaderContext readerContext) throws Exception {
+        return new TiKVSourceReader(tikvParameters, readerContext, deserializationSchema);
+    }
+
+    @Override
+    public Serializer<SingleSplitEnumeratorState> getEnumeratorStateSerializer() {

Review Comment:
   > remove this method
   
   ok,I'm going to modify 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@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] Xuxiaotuan closed pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

Posted by GitBox <gi...@apache.org>.
Xuxiaotuan closed pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink
URL: https://github.com/apache/incubator-seatunnel/pull/2830


-- 
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] Hisoka-X commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on PR #2830:
URL: https://github.com/apache/incubator-seatunnel/pull/2830#issuecomment-1253359040

   Can you add doc to introduce this connector? Reference: https://github.com/apache/incubator-seatunnel/tree/dev/docs/en/connector-v2


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   @Hisoka-X PTAL


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   @Hisoka-X I have fixed some code style issues, please rerun ci workflow again


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

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

   transfer to [[Feature][Connector-V2][TiKV] Support TiKV Source & Sink #3173](https://github.com/apache/incubator-seatunnel/pull/3173)


-- 
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] Carl-Zhou-CN commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

Posted by GitBox <gi...@apache.org>.
Carl-Zhou-CN commented on PR #2830:
URL: https://github.com/apache/incubator-seatunnel/pull/2830#issuecomment-1263184089

   @Xuxiaotuan hi,I am currently completing the e2e of Tidb, but when I use Docker to start the cluster, there is always a problem with the connection between PD and Tidb. Do you know the reason
   
    [util.rs:549] ["PD failed to respond"] [err="Grpc(RpcFailure(RpcStatus { code: 14-UNAVAILABLE, message: \"failed to connect to all addresses\", details: [] }))"] [endpoints=127.0.0.1:2379]
   


-- 
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] Carl-Zhou-CN commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

Posted by GitBox <gi...@apache.org>.
Carl-Zhou-CN commented on PR #2830:
URL: https://github.com/apache/incubator-seatunnel/pull/2830#issuecomment-1288504361

   > > > @Xuxiaotuan hi,I am currently completing the e2e of Tidb, but when I use Docker to start the cluster, there is always a problem with the connection between PD and Tidb. Do you know the reason
   > > > [util.rs:549] ["PD failed to respond"] [err="Grpc(RpcFailure(RpcStatus { code: 14-UNAVAILABLE, message: "failed to connect to all addresses", details: [] }))"] [endpoints=127.0.0.1:2379]
   > > 
   > > 
   > > when accessing between tidb pd and tikv, it is accessed through the internal address side, similar to hadoop xxx:port
   > 
   > https://mp.weixin.qq.com/s/36EzhuTVb6oiUZTUYSJMWg tidb is currently accessible in docker
   
   Thank you. I'll try that, too


-- 
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] Hisoka-X commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on PR #2830:
URL: https://github.com/apache/incubator-seatunnel/pull/2830#issuecomment-1254473745

   You can package in local before you push. So you can find problem eariler.


-- 
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] Hisoka-X commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on PR #2830:
URL: https://github.com/apache/incubator-seatunnel/pull/2830#issuecomment-1253360679

   And tell the user why implementing in Java client is better than JDBC


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   > 
   
   Ok,  thanks, I'm testing locally and there are still some trouble, **so don't review the code first.** 
   
   The simple scenario test passed, but there are still some types that are not compatible, and there are still some problems in requesting tidb in the docker environment. I am dealing with
   
   <img width="1449" alt="image" src="https://user-images.githubusercontent.com/29968120/192156094-885d49c3-c55f-4f7c-a4cc-69d64dd53fdf.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@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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

   /run-all-tests
   


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

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

   > 
   
   I checked and found that when Start only tikv and pd, docker is required to use [host-network-mode-linux](https://github.com/pingcap/tidb-docker-compose#host-network-mode-linux) Because I am using macOS, I encountered some problems, in fact,[“The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.”](https://www.reddit.com/r/docker/comments/uede0r/cannot_access_to_container_with_host_network_mode/)


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

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

   > @Xuxiaotuan hi,I am currently completing the e2e of Tidb, but when I use Docker to start the cluster, there is always a problem with the connection between PD and Tidb. Do you know the reason
   > 
   > [util.rs:549] ["PD failed to respond"] [err="Grpc(RpcFailure(RpcStatus { code: 14-UNAVAILABLE, message: "failed to connect to all addresses", details: [] }))"] [endpoints=127.0.0.1:2379]
   
   when accessing between tidb pd and tikv, it is accessed through the internal address side, similar to hadoop  xxx:port
   


-- 
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] Xuxiaotuan commented on pull request #2830: [Feature][Connector-V2][TiKV] Support TiKV Source & Sink

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

   > > @Xuxiaotuan hi,I am currently completing the e2e of Tidb, but when I use Docker to start the cluster, there is always a problem with the connection between PD and Tidb. Do you know the reason
   > > [util.rs:549] ["PD failed to respond"] [err="Grpc(RpcFailure(RpcStatus { code: 14-UNAVAILABLE, message: "failed to connect to all addresses", details: [] }))"] [endpoints=127.0.0.1:2379]
   > 
   > when accessing between tidb pd and tikv, it is accessed through the internal address side, similar to hadoop xxx:port
   
   https://mp.weixin.qq.com/s/36EzhuTVb6oiUZTUYSJMWg  tidb is currently accessible in docker    


-- 
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] hailin0 commented on a diff in pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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


##########
seatunnel-e2e/seatunnel-flink-connector-v2-e2e/connector-tikv-flink-e2e/src/test/resources/tikv/pd_tikv_contanner_docker_compose.yml:
##########
@@ -0,0 +1,24 @@
+version: '2.1'

Review Comment:
   remove this file



##########
seatunnel-connectors-v2/connector-tikv/src/main/java/org/apache/seatunnel/connectors/seatunnel/tikv/sink/TiKVSinkWriter.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.connectors.seatunnel.tikv.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.ClientSession;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVDataType;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVParameters;
+
+import org.tikv.raw.RawKVClient;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+public class TiKVSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+
+    private final ClientSession clientSession;
+    private final TiKVParameters tikvParameters;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public TiKVSinkWriter(SeaTunnelRowType seaTunnelRowType, TiKVParameters tikvParameters) {
+        this.tikvParameters = tikvParameters;
+        this.clientSession = new ClientSession(tikvParameters);
+        this.seaTunnelRowType = seaTunnelRowType;
+    }
+
+    @Override
+    public void write(SeaTunnelRow seaTunnelRow) {
+        RawKVClient client = clientSession.session.createRawClient();

Review Comment:
   Can it be reused?



##########
seatunnel-connectors-v2/connector-tikv/pom.xml:
##########
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>seatunnel-connectors-v2</artifactId>
+        <groupId>org.apache.seatunnel</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>connector-tikv</artifactId>
+
+    <properties>
+        <tikv-client-java.version>3.3.0</tikv-client-java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.seatunnel</groupId>
+            <artifactId>connector-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.seatunnel</groupId>
+            <artifactId>seatunnel-format-json</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.seatunnel</groupId>
+            <artifactId>seatunnel-api</artifactId>

Review Comment:
   remove this  dependency
   
   https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-connectors-v2/pom.xml#L77



##########
seatunnel-connectors-v2/connector-tikv/src/main/java/org/apache/seatunnel/connectors/seatunnel/tikv/sink/TiKVSinkWriter.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.connectors.seatunnel.tikv.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.ClientSession;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVDataType;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVParameters;
+
+import org.tikv.raw.RawKVClient;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+public class TiKVSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+
+    private final ClientSession clientSession;
+    private final TiKVParameters tikvParameters;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public TiKVSinkWriter(SeaTunnelRowType seaTunnelRowType, TiKVParameters tikvParameters) {
+        this.tikvParameters = tikvParameters;
+        this.clientSession = new ClientSession(tikvParameters);
+        this.seaTunnelRowType = seaTunnelRowType;
+    }
+
+    @Override
+    public void write(SeaTunnelRow seaTunnelRow) {
+        RawKVClient client = clientSession.session.createRawClient();
+        TiKVDataType tikvDataType = tikvParameters.getTikvDataType();
+
+        // todo 需要兼容序列化不同类型的数据 只是key类型

Review Comment:
   use english?



##########
.idea/vcs.xml:
##########
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   revert this file



-- 
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] hailin0 commented on a diff in pull request #2830: [Feature][Connector-V2]new connecotor of TiKV source and sink

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


##########
seatunnel-connectors-v2/connector-tikv/src/main/java/org/apache/seatunnel/connectors/seatunnel/tikv/source/TiKVSource.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.connectors.seatunnel.tikv.source;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.serialization.Serializer;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.connectors.seatunnel.common.schema.SeaTunnelSchema;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitEnumeratorState;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVConfig;
+import org.apache.seatunnel.connectors.seatunnel.tikv.config.TiKVParameters;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(SeaTunnelSource.class)
+public class TiKVSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+
+    private final TiKVParameters tikvParameters = new TiKVParameters();
+
+    private SeaTunnelRowType seaTunnelRowType;
+
+    private DeserializationSchema<SeaTunnelRow> deserializationSchema;
+
+    @Override
+    public String getPluginName() {
+        return TiKVConfig.NAME;
+    }
+
+    /**
+     * init configuration parameters
+     *
+     * @param config plugin config.
+     * @throws PrepareFailException prepare failed
+     */
+    @Override
+    public void prepare(Config config) throws PrepareFailException {
+        CheckResult result = CheckConfigUtil.checkAllExists(config, TiKVConfig.HOST, TiKVConfig.DATA_TYPE, TiKVConfig.DATA_TYPE);
+        if (!result.isSuccess()) {
+            throw new PrepareFailException(getPluginName(), PluginType.SOURCE, result.getMsg());
+        }
+        // init tikv configuration
+        this.tikvParameters.initConfig(config);
+
+        // init seaTunnelRowType
+        if (config.hasPath(SeaTunnelSchema.SCHEMA)) {
+            Config schema = config.getConfig(SeaTunnelSchema.SCHEMA);
+            this.seaTunnelRowType = SeaTunnelSchema.buildWithConfig(schema).getSeaTunnelRowType();
+        } else {
+            this.seaTunnelRowType = SeaTunnelSchema.buildSimpleTextSchema();
+        }
+
+        if (config.hasPath(TiKVConfig.FORMAT)) {
+            this.deserializationSchema = null;
+        } else {
+            this.deserializationSchema = new JsonDeserializationSchema(false, false, seaTunnelRowType);
+        }
+    }
+
+    @Override
+    public Boundedness getBoundedness() {
+        return Boundedness.BOUNDED;
+    }
+
+    @Override
+    public SeaTunnelDataType<SeaTunnelRow> getProducedType() {
+        return seaTunnelRowType;
+    }
+
+    @Override
+    public AbstractSingleSplitReader<SeaTunnelRow> createReader(SingleSplitReaderContext readerContext) throws Exception {
+        return new TiKVSourceReader(tikvParameters, readerContext, deserializationSchema);
+    }
+
+    @Override
+    public Serializer<SingleSplitEnumeratorState> getEnumeratorStateSerializer() {

Review Comment:
   remove this method



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