use of org.apache.flink.client.cli.ExecutionConfigAccessor in project flink by apache.
the class DefaultContext method createExecutionConfig.
private static Configuration createExecutionConfig(CommandLine commandLine, Options commandLineOptions, List<CustomCommandLine> availableCommandLines, List<URL> dependencies) throws FlinkException {
LOG.debug("Available commandline options: {}", commandLineOptions);
List<String> options = Stream.of(commandLine.getOptions()).map(o -> o.getOpt() + "=" + o.getValue()).collect(Collectors.toList());
LOG.debug("Instantiated commandline args: {}, options: {}", commandLine.getArgList(), options);
final CustomCommandLine activeCommandLine = findActiveCommandLine(availableCommandLines, commandLine);
LOG.debug("Available commandlines: {}, active commandline: {}", availableCommandLines, activeCommandLine);
Configuration executionConfig = activeCommandLine.toConfiguration(commandLine);
try {
final ProgramOptions programOptions = ProgramOptions.create(commandLine);
final ExecutionConfigAccessor executionConfigAccessor = ExecutionConfigAccessor.fromProgramOptions(programOptions, dependencies);
executionConfigAccessor.applyToConfiguration(executionConfig);
} catch (CliArgsException e) {
throw new SqlExecutionException("Invalid deployment run options.", e);
}
LOG.info("Executor config: {}", executionConfig);
return executionConfig;
}
use of org.apache.flink.client.cli.ExecutionConfigAccessor in project flink by apache.
the class AbstractJobClusterExecutor method execute.
@Override
public CompletableFuture<JobClient> execute(@Nonnull final Pipeline pipeline, @Nonnull final Configuration configuration, @Nonnull final ClassLoader userCodeClassloader) throws Exception {
final JobGraph jobGraph = PipelineExecutorUtils.getJobGraph(pipeline, configuration);
try (final ClusterDescriptor<ClusterID> clusterDescriptor = clusterClientFactory.createClusterDescriptor(configuration)) {
final ExecutionConfigAccessor configAccessor = ExecutionConfigAccessor.fromConfiguration(configuration);
final ClusterSpecification clusterSpecification = clusterClientFactory.getClusterSpecification(configuration);
final ClusterClientProvider<ClusterID> clusterClientProvider = clusterDescriptor.deployJobCluster(clusterSpecification, jobGraph, configAccessor.getDetachedMode());
LOG.info("Job has been submitted with JobID " + jobGraph.getJobID());
return CompletableFuture.completedFuture(new ClusterClientJobClientAdapter<>(clusterClientProvider, jobGraph.getJobID(), userCodeClassloader));
}
}
use of org.apache.flink.client.cli.ExecutionConfigAccessor in project flink by apache.
the class PipelineExecutorUtils method getJobGraph.
/**
* Creates the {@link JobGraph} corresponding to the provided {@link Pipeline}.
*
* @param pipeline the pipeline whose job graph we are computing
* @param configuration the configuration with the necessary information such as jars and
* classpaths to be included, the parallelism of the job and potential savepoint settings
* used to bootstrap its state.
* @return the corresponding {@link JobGraph}.
*/
public static JobGraph getJobGraph(@Nonnull final Pipeline pipeline, @Nonnull final Configuration configuration) throws MalformedURLException {
checkNotNull(pipeline);
checkNotNull(configuration);
final ExecutionConfigAccessor executionConfigAccessor = ExecutionConfigAccessor.fromConfiguration(configuration);
final JobGraph jobGraph = FlinkPipelineTranslationUtil.getJobGraph(pipeline, configuration, executionConfigAccessor.getParallelism());
configuration.getOptional(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID).ifPresent(strJobID -> jobGraph.setJobID(JobID.fromHexString(strJobID)));
jobGraph.addJars(executionConfigAccessor.getJars());
jobGraph.setClasspaths(executionConfigAccessor.getClasspaths());
jobGraph.setSavepointRestoreSettings(executionConfigAccessor.getSavepointRestoreSettings());
return jobGraph;
}
Aggregations