You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by GitBox <gi...@apache.org> on 2022/06/06 08:26:34 UTC

[GitHub] [incubator-hugegraph-toolchain] simon824 commented on a diff in pull request #291: feat: Introduce HugeGraphFlinkCDCLoader

simon824 commented on code in PR #291:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/291#discussion_r889930865


##########
hugegraph-loader/src/main/java/com/baidu/hugegraph/loader/flink/HugeGraphFlinkCDCLoader.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * 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 com.baidu.hugegraph.loader.flink;
+
+import static java.util.regex.Pattern.compile;
+
+import java.util.List;
+import java.util.regex.Matcher;
+
+import org.apache.flink.api.common.eventtime.WatermarkStrategy;
+import org.apache.flink.streaming.api.datastream.DataStreamSource;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.slf4j.Logger;
+
+import com.baidu.hugegraph.loader.constant.Constants;
+import com.baidu.hugegraph.loader.executor.LoadOptions;
+import com.baidu.hugegraph.loader.mapping.InputStruct;
+import com.baidu.hugegraph.loader.mapping.LoadMapping;
+import com.baidu.hugegraph.loader.source.jdbc.JDBCSource;
+import com.baidu.hugegraph.loader.util.Printer;
+import com.baidu.hugegraph.util.E;
+import com.baidu.hugegraph.util.Log;
+import com.ververica.cdc.connectors.mysql.source.MySqlSource;
+
+public class HugeGraphFlinkCDCLoader {
+    public static final Logger LOG = Log.logger(HugeGraphFlinkCDCLoader.class);
+
+    private final LoadOptions loadOptions;
+    private final String[] options;
+
+    public HugeGraphFlinkCDCLoader(String[] args) {
+        this.options = args;
+        this.loadOptions = LoadOptions.parseOptions(args);
+    }
+
+    public static void main(String[] args) {
+        HugeGraphFlinkCDCLoader loader;
+        try {
+            loader = new HugeGraphFlinkCDCLoader(args);
+        } catch (Throwable e) {
+            Printer.printError("Failed to start loading", e);
+            return;
+        }
+        loader.load();
+    }
+
+    public void load() {
+        LoadMapping mapping = LoadMapping.of(this.loadOptions.file);
+        List<InputStruct> structs = mapping.structs();
+        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
+
+        for (InputStruct struct : structs) {
+            JDBCSource input = (JDBCSource) struct.input();
+            String host = "";
+            int port = -1;
+            Matcher m = compile(Constants.HOST_PORT_REGEX).matcher(input.url());

Review Comment:
   URL cannot parse url like this `jdbc:mysql://127.0.0.1:3306`
   



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

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