Search in sources :

Example 1 with DeployMode

use of com.flink.platform.common.enums.DeployMode in project flink-platform-backend by itinycheng.

the class FlinkCommandBuilder method buildCommand.

@Override
public JobCommand buildCommand(JobInfo jobInfo) throws Exception {
    FlinkCommand command = new FlinkCommand();
    DeployMode deployMode = jobInfo.getDeployMode();
    String execMode = String.format(EXEC_MODE, deployMode.mode, deployMode.target);
    command.setPrefix(flinkConfig.getCommandPath() + execMode);
    // add configurations
    Map<String, Object> configs = command.getConfigs();
    if (jobInfo.getConfigs() != null) {
        configs.putAll(jobInfo.getConfigs());
    }
    // add yarn application name
    String appName = String.join("-", jobInfo.getExecMode().name(), jobInfo.getCode());
    configs.put(YARN_APPLICATION_NAME, appName);
    // add lib dirs and user classpaths
    List<String> extJarList = ListUtils.defaultIfNull(jobInfo.getExtJars(), Collections.emptyList());
    configs.put(YARN_PROVIDED_LIB_DIRS, getMergedLibDirs(extJarList));
    List<URL> classpaths = getOrCreateClasspaths(jobInfo.getCode(), extJarList);
    command.setClasspaths(classpaths);
    switch(jobInfo.getType()) {
        case FLINK_JAR:
            command.setMainJar(jobInfo.getSubject());
            command.setMainArgs(jobInfo.getMainArgs());
            command.setMainClass(jobInfo.getMainClass());
            break;
        case FLINK_SQL:
            String localJarPath = getLocalPathOfSqlJarFile();
            String filePath = sqlContextHelper.convertFromAndSaveToFile(jobInfo);
            command.setMainArgs(filePath);
            command.setMainJar(localJarPath);
            command.setMainClass(flinkConfig.getClassName());
            break;
        default:
            throw new JobCommandGenException("unsupported job type");
    }
    return command;
}
Also used : DeployMode(com.flink.platform.common.enums.DeployMode) JobCommandGenException(com.flink.platform.common.exception.JobCommandGenException) URL(java.net.URL)

Aggregations

DeployMode (com.flink.platform.common.enums.DeployMode)1 JobCommandGenException (com.flink.platform.common.exception.JobCommandGenException)1 URL (java.net.URL)1