public void exec() throws Exception {
        JobGraph jobGraph = JobGraphBuildUtil.buildJobGraph(jobParamsInfo);
        Configuration flinkConfiguration = JobGraphBuildUtil.getFlinkConfiguration(jobParamsInfo.getFlinkConfDir(), jobParamsInfo.getConfProperties());
        ClusterDescriptor clusterDescriptor = YarnClusterClientFactory.INSTANCE.createClusterDescriptor(jobParamsInfo.getYarnConfDir(), flinkConfiguration);

        try {
            Object yid = jobParamsInfo.getYarnSessionConfProperties().get("yid");
            if (null == yid) {
                throw new RuntimeException("yarnSessionMode yid is required");
            }

            ApplicationId applicationId = ConverterUtils.toApplicationId(yid.toString());
            ClusterClientProvider<ApplicationId> retrieve = clusterDescriptor.retrieve(applicationId);
            ClusterClient<ApplicationId> clusterClient = retrieve.getClusterClient();

            if (StringUtils.equalsIgnoreCase(jobParamsInfo.getPluginLoadMode(), EPluginLoadMode.SHIPFILE.name())) {
                jobGraph.getUserArtifacts().clear();
            } else {
                JobGraphBuildUtil.fillJobGraphClassPath(jobGraph);
            }

            if (!StringUtils.isEmpty(jobParamsInfo.getUdfJar())) {
                JobGraphBuildUtil.fillUserJarForJobGraph(jobParamsInfo.getUdfJar(), jobGraph);
            }

            JobExecutionResult jobExecutionResult = ClientUtils.submitJob(clusterClient, jobGraph);
            String jobId = jobExecutionResult.getJobID().toString();
            LOG.info("jobID:" + jobId);
        } finally {
            try {
                clusterDescriptor.close();
            } catch (Exception e) {
                LOG.info("Could not properly close the yarn cluster descriptor.", e);
            }
        }


    }
Date: 2020/3/4
Company: www.dtstack.com
@author maqi
launcher/src/main/java/com/dtstack/flink/sql/launcher/executor/YarnSessionClusterExecutor.java