MonsterChenzhuo commented on code in PR #1809:
URL: https://github.com/apache/incubator-paimon/pull/1809#discussion_r1295567176


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/mongodb/MongoDBSyncDatabaseActionFactory.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.paimon.flink.action.cdc.mongodb;
+
+import org.apache.paimon.flink.action.Action;
+import org.apache.paimon.flink.action.ActionFactory;
+
+import org.apache.flink.api.java.utils.MultipleParameterTool;
+
+import java.util.Map;
+import java.util.Optional;
+
+/** Factory to create {@link MongoDBSyncDatabaseAction}. */
+public class MongoDBSyncDatabaseActionFactory implements ActionFactory {
+
+    public static final String IDENTIFIER = "mongodb-sync-database";
+
+    @Override
+    public String identifier() {
+        return IDENTIFIER;
+    }
+
+    @Override
+    public Optional<Action> create(MultipleParameterTool params) {
+        checkRequiredArgument(params, "warehouse");
+        checkRequiredArgument(params, "database");
+        checkRequiredArgument(params, "mongodb-conf");
+
+        String warehouse = params.get("warehouse");
+        String database = params.get("database");
+        boolean mergeShards =
+                !params.has("merge-shards") || 
Boolean.parseBoolean(params.get("merge-shards"));
+        String tablePrefix = params.get("table-prefix");
+        String tableSuffix = params.get("table-suffix");
+        String includingTables = params.get("including-tables");
+        String excludingTables = params.get("excluding-tables");
+
+        Map<String, String> mongodbConfigOption = optionalConfigMap(params, 
"mongodb-conf");
+        Map<String, String> catalogConfigOption = optionalConfigMap(params, 
"catalog-conf");
+        Map<String, String> tableConfigOption = optionalConfigMap(params, 
"table-conf");
+        return Optional.of(
+                new MongoDBSyncDatabaseAction(
+                        mongodbConfigOption,
+                        warehouse,
+                        database,
+                        mergeShards,
+                        tablePrefix,
+                        tableSuffix,
+                        includingTables,
+                        excludingTables,
+                        catalogConfigOption,
+                        tableConfigOption));
+    }
+
+    @Override
+    public void printHelp() {
+        System.out.println(
+                "Action \"mongodb-sync-database\" creates a streaming job "
+                        + "with a Flink MongoDB CDC source and multiple Paimon 
table sinks "
+                        + "to synchronize a whole MongoDB database into one 
Paimon database.\n"
+                        + "Only MongoDB tables with primary keys will be 
considered. "
+                        + "Newly created MongoDB tables after the job starts 
will not be included.");
+        System.out.println();
+
+        System.out.println("Syntax:");
+        System.out.println(
+                "  mongodb-sync-database --warehouse <warehouse-path> 
--database <database-name> "
+                        + "[--merge-shards <true/false>] "

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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to