Search in sources :

Example 1 with ExecutionConfigAccessor

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;
}
Also used : Executor(org.apache.flink.table.client.gateway.Executor) FlinkException(org.apache.flink.util.FlinkException) CliFrontendParser(org.apache.flink.client.cli.CliFrontendParser) Logger(org.slf4j.Logger) CliArgsException(org.apache.flink.client.cli.CliArgsException) ProgramOptions(org.apache.flink.client.cli.ProgramOptions) URL(java.net.URL) CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) ExecutionConfigAccessor(org.apache.flink.client.cli.ExecutionConfigAccessor) Configuration(org.apache.flink.configuration.Configuration) Options(org.apache.commons.cli.Options) LoggerFactory(org.slf4j.LoggerFactory) SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) FileSystem(org.apache.flink.core.fs.FileSystem) PluginUtils(org.apache.flink.core.plugin.PluginUtils) CommandLine(org.apache.commons.cli.CommandLine) CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) Configuration(org.apache.flink.configuration.Configuration) ExecutionConfigAccessor(org.apache.flink.client.cli.ExecutionConfigAccessor) CliArgsException(org.apache.flink.client.cli.CliArgsException) ProgramOptions(org.apache.flink.client.cli.ProgramOptions)

Example 2 with ExecutionConfigAccessor

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));
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) ExecutionConfigAccessor(org.apache.flink.client.cli.ExecutionConfigAccessor)

Example 3 with ExecutionConfigAccessor

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;
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ExecutionConfigAccessor(org.apache.flink.client.cli.ExecutionConfigAccessor)

Aggregations

ExecutionConfigAccessor (org.apache.flink.client.cli.ExecutionConfigAccessor)3 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 URL (java.net.URL)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 CommandLine (org.apache.commons.cli.CommandLine)1 Options (org.apache.commons.cli.Options)1 CliArgsException (org.apache.flink.client.cli.CliArgsException)1 CliFrontendParser (org.apache.flink.client.cli.CliFrontendParser)1 CustomCommandLine (org.apache.flink.client.cli.CustomCommandLine)1 ProgramOptions (org.apache.flink.client.cli.ProgramOptions)1 ClusterSpecification (org.apache.flink.client.deployment.ClusterSpecification)1 Configuration (org.apache.flink.configuration.Configuration)1 FileSystem (org.apache.flink.core.fs.FileSystem)1 PluginUtils (org.apache.flink.core.plugin.PluginUtils)1 Executor (org.apache.flink.table.client.gateway.Executor)1 SqlExecutionException (org.apache.flink.table.client.gateway.SqlExecutionException)1 FlinkException (org.apache.flink.util.FlinkException)1 Logger (org.slf4j.Logger)1