-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][task-flink] Support Flink application mode
- Loading branch information
Showing
9 changed files
with
271 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...sk-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkDeployMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.dolphinscheduler.plugin.task.flink; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Flink deploy mode | ||
*/ | ||
public enum FlinkDeployMode { | ||
@JsonProperty("local") | ||
LOCAL, | ||
@JsonProperty("cluster") | ||
CLUSTER, | ||
@JsonProperty("application") | ||
APPLICATION | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* 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.dolphinscheduler.plugin.task.flink; | ||
|
||
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
public class FlinkArgsUtilsTest { | ||
|
||
private String joinStringListWithSpace(List<String> stringList) { | ||
return String.join(" ", stringList); | ||
} | ||
|
||
private FlinkParameters buildTestFlinkParametersWithDeployMode(FlinkDeployMode flinkDeployMode) { | ||
FlinkParameters flinkParameters = new FlinkParameters(); | ||
flinkParameters.setProgramType(ProgramType.SCALA); | ||
flinkParameters.setDeployMode(flinkDeployMode); | ||
flinkParameters.setParallelism(4); | ||
ResourceInfo resourceInfo = new ResourceInfo(); | ||
resourceInfo.setId(1); | ||
resourceInfo.setResourceName("job"); | ||
resourceInfo.setRes("/opt/job.jar"); | ||
flinkParameters.setMainJar(resourceInfo); | ||
flinkParameters.setMainClass("org.example.Main"); | ||
|
||
return flinkParameters; | ||
} | ||
|
||
@Test | ||
public void testApplicationMode() throws Exception { | ||
FlinkParameters flinkParameters = buildTestFlinkParametersWithDeployMode(FlinkDeployMode.APPLICATION); | ||
List<String> commandLine = FlinkArgsUtils.buildCommandLine(flinkParameters); | ||
|
||
Assert.assertEquals( | ||
"flink run-application -t yarn-application -p 4 -sae -c org.example.Main /opt/job.jar", | ||
joinStringListWithSpace(commandLine)); | ||
} | ||
|
||
@Test | ||
public void testClusterMode() throws Exception { | ||
FlinkParameters flinkParameters = buildTestFlinkParametersWithDeployMode(FlinkDeployMode.CLUSTER); | ||
flinkParameters.setFlinkVersion("1.11"); | ||
List<String> commandLine1 = FlinkArgsUtils.buildCommandLine(flinkParameters); | ||
|
||
Assert.assertEquals( | ||
"flink run -m yarn-cluster -p 4 -sae -c org.example.Main /opt/job.jar", | ||
joinStringListWithSpace(commandLine1)); | ||
|
||
flinkParameters.setFlinkVersion("<1.10"); | ||
List<String> commandLine2 = FlinkArgsUtils.buildCommandLine(flinkParameters); | ||
|
||
Assert.assertEquals( | ||
"flink run -m yarn-cluster -p 4 -sae -c org.example.Main /opt/job.jar", | ||
joinStringListWithSpace(commandLine2)); | ||
|
||
flinkParameters.setFlinkVersion(">=1.12"); | ||
List<String> commandLine3 = FlinkArgsUtils.buildCommandLine(flinkParameters); | ||
|
||
Assert.assertEquals( | ||
"flink run -t yarn-per-job -p 4 -sae -c org.example.Main /opt/job.jar", | ||
joinStringListWithSpace(commandLine3)); | ||
} | ||
|
||
@Test | ||
public void testLocalMode() throws Exception { | ||
FlinkParameters flinkParameters = buildTestFlinkParametersWithDeployMode(FlinkDeployMode.LOCAL); | ||
List<String> commandLine = FlinkArgsUtils.buildCommandLine(flinkParameters); | ||
|
||
Assert.assertEquals( | ||
"flink run -p 4 -sae -c org.example.Main /opt/job.jar", | ||
joinStringListWithSpace(commandLine)); | ||
} | ||
} |
Oops, something went wrong.