Search in sources :

Example 1 with ProgramOptions

use of org.apache.flink.client.cli.ProgramOptions in project flink by apache.

the class CliFrontendPackageProgramTest method testFileNotJarFile.

@Test
public void testFileNotJarFile() {
    try {
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        ProgramOptions options = mock(ProgramOptions.class);
        when(options.getJarFilePath()).thenReturn(getNonJarFilePath());
        try {
            frontend.buildProgram(options);
            fail("should throw an exception");
        } catch (ProgramInvocationException e) {
        // that's what we want
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) ProgramOptions(org.apache.flink.client.cli.ProgramOptions) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) FileNotFoundException(java.io.FileNotFoundException) CompilerException(org.apache.flink.optimizer.CompilerException) Test(org.junit.Test)

Example 2 with ProgramOptions

use of org.apache.flink.client.cli.ProgramOptions in project flink by apache.

the class CliFrontendPackageProgramTest method testNonExistingJarFile.

@Test
public void testNonExistingJarFile() {
    try {
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        ProgramOptions options = mock(ProgramOptions.class);
        when(options.getJarFilePath()).thenReturn("/some/none/existing/path");
        try {
            frontend.buildProgram(options);
            fail("should throw an exception");
        } catch (FileNotFoundException e) {
        // that's what we want
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) ProgramOptions(org.apache.flink.client.cli.ProgramOptions) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) FileNotFoundException(java.io.FileNotFoundException) CompilerException(org.apache.flink.optimizer.CompilerException) Test(org.junit.Test)

Example 3 with ProgramOptions

use of org.apache.flink.client.cli.ProgramOptions 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)

Aggregations

ProgramOptions (org.apache.flink.client.cli.ProgramOptions)3 FileNotFoundException (java.io.FileNotFoundException)2 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)2 CompilerException (org.apache.flink.optimizer.CompilerException)2 Test (org.junit.Test)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 ExecutionConfigAccessor (org.apache.flink.client.cli.ExecutionConfigAccessor)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