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/05/22 01:37:08 UTC

[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1939: [API-DRAFT]refactor api base

ruanwenjun commented on code in PR #1939:
URL: https://github.com/apache/incubator-seatunnel/pull/1939#discussion_r878779694


##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/command/FlinkApiConfValidateCommand.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.core.starter.command;
+
+import org.apache.seatunnel.core.starter.args.FlinkCommandArgs;
+import org.apache.seatunnel.core.starter.config.ConfigBuilder;
+import org.apache.seatunnel.core.starter.config.FlinkApiConfigChecker;
+import org.apache.seatunnel.core.starter.exception.ConfigCheckException;
+import org.apache.seatunnel.core.starter.utils.FileUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.file.Path;
+
+/**
+ * Used to check the Flink conf is validated.
+ */
+public class FlinkApiConfValidateCommand implements Command<FlinkCommandArgs> {

Review Comment:
   This class it used in our old flink job, we don't need this in our new API module.



##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/command/FlinkCommandBuilder.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.core.starter.command;
+
+import org.apache.seatunnel.common.config.Common;
+import org.apache.seatunnel.core.starter.args.FlinkCommandArgs;
+
+public class FlinkCommandBuilder implements CommandBuilder<FlinkCommandArgs> {
+
+    @Override
+    public Command<FlinkCommandArgs> buildCommand(FlinkCommandArgs commandArgs) {
+        if (Boolean.FALSE.equals(Common.setDeployMode(commandArgs.getDeployMode().getName()))) {
+            throw new IllegalArgumentException(
+                String.format("Deploy mode: %s is Illegal", commandArgs.getDeployMode()));
+        }
+        switch (commandArgs.getApiType()) {
+            case ENGINE_API:
+                return new FlinkApiCommandBuilder().buildCommand(commandArgs);
+            case SEATUNNEL_API:
+                return new SeaTunnelApiCommandBuilder().buildCommand(commandArgs);
+            default:
+                throw new IllegalArgumentException("Unsupported API type: " + commandArgs.getApiType());

Review Comment:
   We also don't need to do this judge.



##########
seatunnel-examples/seatunnel-flink-examples/src/main/java/org/apache/seatunnel/example/flink/LocalFlinkExample.java:
##########
@@ -17,11 +17,11 @@
 
 package org.apache.seatunnel.example.flink;
 
-import org.apache.seatunnel.core.base.Seatunnel;
-import org.apache.seatunnel.core.base.command.Command;
-import org.apache.seatunnel.core.base.exception.CommandException;
-import org.apache.seatunnel.core.flink.args.FlinkCommandArgs;
-import org.apache.seatunnel.core.flink.command.FlinkCommandBuilder;
+import org.apache.seatunnel.core.starter.Seatunnel;

Review Comment:
   The class `LocalFlinkExample` can be deleted in our new module.



##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/args/FlinkCommandArgs.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.core.starter.args;
+
+import org.apache.seatunnel.common.config.DeployMode;
+import org.apache.seatunnel.core.starter.command.AbstractCommandArgs;
+import org.apache.seatunnel.core.starter.config.ApiType;
+import org.apache.seatunnel.core.starter.config.EngineType;
+import org.apache.seatunnel.core.starter.config.FlinkRunMode;
+
+import com.beust.jcommander.IStringConverter;
+import com.beust.jcommander.Parameter;
+
+import java.util.List;
+
+public class FlinkCommandArgs extends AbstractCommandArgs {
+
+    @Parameter(names = {"-r", "--run-mode"},
+        converter = RunModeConverter.class,
+        description = "job run mode, run or run-application")
+    private FlinkRunMode runMode = FlinkRunMode.RUN;
+
+    @Parameter(names = {"-api", "--api-type"},
+        converter = ApiTypeConverter.class,
+        description = "Api type, engine or seatunnel")
+    private ApiType apiType = ApiType.ENGINE_API;

Review Comment:
   We can remove this parameter, in our new module we don't need this.



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