SteNicholas commented on code in PR #237:
URL: https://github.com/apache/paimon-webui/pull/237#discussion_r1609404332


##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/ActionContextFactoryServiceLoadUtil.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.web.api.action.context.factory;
+
+import org.apache.paimon.web.api.enums.FlinkCdcType;
+import org.apache.paimon.web.api.exception.ActionException;
+
+import java.util.Objects;
+import java.util.ServiceLoader;
+
+/** ActionContextFactoryServiceLoadUtil. */
+public class ActionContextFactoryServiceLoadUtil {
+
+    private ActionContextFactoryServiceLoadUtil() {}
+
+    public static FlinkCdcActionContextFactory getFlinkCdcActionContextFactory(
+            String sourceType, String targetType, FlinkCdcType flinkCdcType) {
+        ServiceLoader<FlinkCdcActionContextFactory> serviceLoader =
+                ServiceLoader.load(FlinkCdcActionContextFactory.class);
+        for (FlinkCdcActionContextFactory factory : serviceLoader) {
+            if (factory.cdcType() == flinkCdcType
+                    && Objects.equals(factory.sourceType(), sourceType)
+                    && Objects.equals(factory.targetType(), targetType)) {
+                return factory;
+            }
+        }
+        throw new ActionException("Could not find suitable 
ActionContextFactory.");

Review Comment:
   ```suggestion
           throw new ActionException("Could not find suitable 
FlinkCdcActionContextFactory.");
   ```



##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/action/service/FlinkCdcActionService.java:
##########
@@ -63,6 +69,24 @@ public ActionExecutionResult execute(ActionContext 
actionContext) throws Excepti
         try {
             List<String> command = getCommand(flinkActionContext);
             Process process = new ShellService(flinkHome, command).execute();
+            shellExecutor.execute(
+                    () -> {
+                        try (InputStream inputStream = 
process.getInputStream();
+                                InputStream errorStream = 
process.getErrorStream(); ) {
+                            List<String> logLines =
+                                    IOUtils.readLines(inputStream, 
StandardCharsets.UTF_8);
+                            for (String logLine : logLines) {
+                                log.info(logLine);
+                            }
+                            List<String> errorLines =
+                                    IOUtils.readLines(errorStream, 
StandardCharsets.UTF_8);
+                            for (String logLine : errorLines) {
+                                log.error(logLine);
+                            }
+                        } catch (Exception e) {
+                            log.info(e.getMessage(), e);

Review Comment:
   ```suggestion
                               log.error(e.getMessage(), e);
   ```



##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcType.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.web.api.enums;
+
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/** FlinkCdcType. */
+@Getter
+public enum FlinkCdcType {

Review Comment:
   ```suggestion
   public enum FlinkCdcSyncType {
   ```



##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/FlinkCdcActionContextFactory.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.web.api.action.context.factory;
+
+import org.apache.paimon.web.api.action.context.ActionContext;
+import org.apache.paimon.web.api.enums.FlinkCdcType;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/** FlinkCdcActionContextFactory. */
+public interface FlinkCdcActionContextFactory {

Review Comment:
   We should also introduce `CdcActionContextFactory`. The 
`FlinkCdcActionContextFactory` extends `CdcActionContextFactory`.



##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcType.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.web.api.enums;
+
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/** FlinkCdcType. */
+@Getter
+public enum FlinkCdcType {
+    SINGLE_TABLE_SYNC(0),
+    ALL_DATABASES_SYNC(1);
+
+    private final Integer value;
+
+    private static final Map<Integer, FlinkCdcType> enumsMap;
+
+    static {
+        enumsMap =
+                Arrays.stream(FlinkCdcType.values())
+                        .collect(Collectors.toMap(FlinkCdcType::getValue, 
Function.identity()));
+    }
+
+    FlinkCdcType(Integer value) {
+        this.value = value;
+    }
+
+    public static FlinkCdcType valueOf(Integer value) {
+        if (enumsMap.containsKey(value)) {
+            return enumsMap.get(value);
+        }
+        throw new RuntimeException("Invalid cdc type.");

Review Comment:
   ```suggestion
           throw new RuntimeException("Invalid cdc sync type.");
   ```



##########
paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/MysqlSyncTableActionContextFactory.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.web.api.action.context.factory;
+
+import org.apache.paimon.web.api.action.context.ActionContext;
+import org.apache.paimon.web.api.action.context.ActionContextUtil;
+import org.apache.paimon.web.api.action.context.MysqlSyncTableActionContext;
+import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
+import org.apache.paimon.web.api.enums.FlinkCdcType;
+import org.apache.paimon.web.api.enums.FlinkJobType;
+import org.apache.paimon.web.common.util.JSONUtils;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.auto.service.AutoService;
+
+/** MysqlSyncTableActionContextFactory. */
+@AutoService(FlinkCdcActionContextFactory.class)
+public class MysqlSyncTableActionContextFactory implements 
FlinkCdcActionContextFactory {
+
+    @Override
+    public String sourceType() {
+        return "MySQL";

Review Comment:
   Could you introduce enum for datasource?



##########
paimon-web-ui/src/form-lib/cdc/use-paimon.ts:
##########
@@ -50,7 +50,6 @@ export function usePaimon(item: any) {
                                        placeholder: '',
                                },
                                options: catalogOptions
-                               

Review Comment:
   Revert this change.



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