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/06/17 10:31:21 UTC

[GitHub] [incubator-seatunnel] wuchunfu opened a new pull request, #2029: [api-draft][connector] Add MongoDB source connector

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

   <!--
   
   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.-->
   close #2023
   
   ## 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] EricJoy2048 commented on pull request #2029: [api-draft][connector] Add MongoDB source connector

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

   Can you submit the document of this connector together in this PR?


-- 
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] EricJoy2048 commented on pull request #2029: [api-draft][connector] Add MongoDB source connector

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

   Is there any other way for us to complete the merger of this PR as soon as possible?


-- 
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 closed pull request #2029: [api-draft][connector] Add MongoDB source connector

Posted by GitBox <gi...@apache.org>.
Hisoka-X closed pull request #2029: [api-draft][connector] Add MongoDB source connector
URL: https://github.com/apache/incubator-seatunnel/pull/2029


-- 
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 #2029: [api-draft][connector] Add MongoDB source connector

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

   @CalvinKirs @ruanwenjun PTAL, thx.


-- 
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 #2029: [api-draft][connector] Add MongoDB source connector

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

   > Can you submit the document of this connector together in this PR?
   
   @EricJoy2048 Ok, I will finish it later.


-- 
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] CalvinKirs commented on pull request #2029: [api-draft][connector] Add MongoDB source connector

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

   https://github.com/mongodb/mongo-java-driver/blob/3.12.x/THIRD-PARTY-NOTICES  please add this to `NOTICE` 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] EricJoy2048 commented on pull request #2029: [api-draft][connector] Add MongoDB source connector

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

   Hi, are there any new updates about this issue. Are there any difficulties that need the help of the community?


-- 
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 a diff in pull request #2029: [api-draft][connector] Add MongoDB source connector

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2029:
URL: https://github.com/apache/incubator-seatunnel/pull/2029#discussion_r900922636


##########
seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/MongodbSourceSplitEnumerator.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.mongodb.source;
+
+import org.apache.seatunnel.api.source.SourceSplitEnumerator;
+import org.apache.seatunnel.connectors.seatunnel.mongodb.state.MongodbSourceState;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+public class MongodbSourceSplitEnumerator implements SourceSplitEnumerator<MongodbSourceSplit, MongodbSourceState> {
+
+    private final Context<MongodbSourceSplit> context;
+
+    private final Set<Integer> readers;
+
+    private volatile int assigned = -1;
+
+    MongodbSourceSplitEnumerator(Context<MongodbSourceSplit> enumeratorContext) {
+        this.context = enumeratorContext;
+        this.readers = new HashSet<>();
+    }
+
+    @Override
+    public void open() {
+
+    }
+
+    @Override
+    public void run() throws Exception {
+
+    }
+
+    @Override
+    public void close() throws IOException {
+
+    }
+
+    @Override
+    public void addSplitsBack(List<MongodbSourceSplit> splits, int subtaskId) {
+        if (splits.isEmpty()) {
+            return;
+        }
+        if (subtaskId == assigned) {
+            Optional<Integer> otherReader = readers.stream().filter(r -> r != subtaskId).findAny();
+            if (otherReader.isPresent()) {
+                context.assignSplit(otherReader.get(), splits);
+            } else {
+                assigned = -1;
+            }
+        }
+    }
+
+    @Override
+    public int currentUnassignedSplitSize() {
+        return assigned < 0 ? 0 : 1;
+    }
+
+    @Override
+    public void handleSplitRequest(int subtaskId) {
+
+    }
+
+    @Override
+    public void registerReader(int subtaskId) {
+        readers.add(subtaskId);
+        if (assigned < 0) {
+            assigned = subtaskId;
+            context.assignSplit(subtaskId, new MongodbSourceSplit());

Review Comment:
   Sorry I miss something.



-- 
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] CalvinKirs commented on pull request #2029: [api-draft][connector] Add MongoDB source connector

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

   > https://github.com/mongodb/mongo-java-driver/blob/3.12.x/THIRD-PARTY-NOTICES please add this to `NOTICE` file
   
   Usually, for the other party's NOTICE, we also need to keep 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] CalvinKirs commented on a diff in pull request #2029: [api-draft][connector] Add MongoDB source connector

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


##########
tools/dependencies/known-dependencies-jdk11.txt:
##########
@@ -507,7 +507,10 @@ metrics-core-3.2.1.jar
 metrics-core-4.0.0.jar
 minlog-1.3.0.jar
 mongo-java-driver-3.4.2.jar
+mongodb-driver-3.12.11.jar
+mongodb-driver-core-3.12.11.jar
 mongo-spark-connector_2.11-2.2.0.jar

Review Comment:
   https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-dist/release-docs/LICENSE



-- 
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 a diff in pull request #2029: [api-draft][connector] Add MongoDB source connector

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2029:
URL: https://github.com/apache/incubator-seatunnel/pull/2029#discussion_r900920859


##########
seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/MongodbSourceSplitEnumerator.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.mongodb.source;
+
+import org.apache.seatunnel.api.source.SourceSplitEnumerator;
+import org.apache.seatunnel.connectors.seatunnel.mongodb.state.MongodbSourceState;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+public class MongodbSourceSplitEnumerator implements SourceSplitEnumerator<MongodbSourceSplit, MongodbSourceState> {
+
+    private final Context<MongodbSourceSplit> context;
+
+    private final Set<Integer> readers;
+
+    private volatile int assigned = -1;
+
+    MongodbSourceSplitEnumerator(Context<MongodbSourceSplit> enumeratorContext) {
+        this.context = enumeratorContext;
+        this.readers = new HashSet<>();
+    }
+
+    @Override
+    public void open() {
+
+    }
+
+    @Override
+    public void run() throws Exception {
+
+    }
+
+    @Override
+    public void close() throws IOException {
+
+    }
+
+    @Override
+    public void addSplitsBack(List<MongodbSourceSplit> splits, int subtaskId) {
+        if (splits.isEmpty()) {
+            return;
+        }
+        if (subtaskId == assigned) {
+            Optional<Integer> otherReader = readers.stream().filter(r -> r != subtaskId).findAny();
+            if (otherReader.isPresent()) {
+                context.assignSplit(otherReader.get(), splits);
+            } else {
+                assigned = -1;
+            }
+        }
+    }
+
+    @Override
+    public int currentUnassignedSplitSize() {
+        return assigned < 0 ? 0 : 1;
+    }
+
+    @Override
+    public void handleSplitRequest(int subtaskId) {
+
+    }
+
+    @Override
+    public void registerReader(int subtaskId) {
+        readers.add(subtaskId);
+        if (assigned < 0) {
+            assigned = subtaskId;
+            context.assignSplit(subtaskId, new MongodbSourceSplit());

Review Comment:
   If every reader will get same split, will it cause duplicate data to be read?



-- 
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] CalvinKirs commented on a diff in pull request #2029: [api-draft][connector] Add MongoDB source connector

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


##########
tools/dependencies/known-dependencies-jdk11.txt:
##########
@@ -507,7 +507,10 @@ metrics-core-3.2.1.jar
 metrics-core-4.0.0.jar
 minlog-1.3.0.jar
 mongo-java-driver-3.4.2.jar
+mongodb-driver-3.12.11.jar
+mongodb-driver-core-3.12.11.jar
 mongo-spark-connector_2.11-2.2.0.jar

Review Comment:
   The newly added jar is not reflected in the license



-- 
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 #2029: [api-draft][connector] Add MongoDB source connector

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

   @CalvinKirs @ruanwenjun @ashulin @Hisoka-X PTAL, thx.


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