Search in sources :

Example 6 with RunOptions

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

the class FlinkYarnSessionCliTest method testCorrectSettingOfMaxSlots.

@Test
public void testCorrectSettingOfMaxSlots() throws Exception {
    File confFile = tmp.newFile("flink-conf.yaml");
    File jarFile = tmp.newFile("test.jar");
    new CliFrontend(tmp.getRoot().getAbsolutePath());
    String[] params = new String[] { "-yn", "2", "-ys", "3", jarFile.getAbsolutePath() };
    RunOptions runOptions = CliFrontendParser.parseRunCommand(params);
    FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");
    AbstractYarnClusterDescriptor descriptor = yarnCLI.createDescriptor("", runOptions.getCommandLine());
    // each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
    Assert.assertEquals(3, descriptor.getTaskManagerSlots());
    Assert.assertEquals(2, descriptor.getTaskManagerCount());
    Configuration config = new Configuration();
    CliFrontend.setJobManagerAddressInConfig(config, new InetSocketAddress("test", 9000));
    ClusterClient client = new TestingYarnClusterClient(descriptor, config);
    Assert.assertEquals(6, client.getMaxSlots());
}
Also used : ClusterClient(org.apache.flink.client.program.ClusterClient) Configuration(org.apache.flink.configuration.Configuration) InetSocketAddress(java.net.InetSocketAddress) CliFrontend(org.apache.flink.client.CliFrontend) File(java.io.File) RunOptions(org.apache.flink.client.cli.RunOptions) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 7 with RunOptions

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

the class CliFrontendAddressConfigurationTest method testManualOptionsOverridesConfig.

@Test
public void testManualOptionsOverridesConfig() {
    try {
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        RunOptions options = CliFrontendParser.parseRunCommand(new String[] { "-m", "203.0.113.22:7788" });
        ClusterClient client = frontend.retrieveClient(options);
        Configuration config = client.getFlinkConfiguration();
        InetSocketAddress expectedAddress = new InetSocketAddress("203.0.113.22", 7788);
        checkJobManagerAddress(config, expectedAddress.getHostName(), expectedAddress.getPort());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ClusterClient(org.apache.flink.client.program.ClusterClient) Configuration(org.apache.flink.configuration.Configuration) InetSocketAddress(java.net.InetSocketAddress) RunOptions(org.apache.flink.client.cli.RunOptions) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Example 8 with RunOptions

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

the class CliFrontendPackageProgramTest method testNonExistingFileWithoutArguments.

@Test
public void testNonExistingFileWithoutArguments() {
    try {
        String[] arguments = { "/some/none/existing/path" };
        RunOptions options = CliFrontendParser.parseRunCommand(arguments);
        assertEquals(arguments[0], options.getJarFilePath());
        assertArrayEquals(new String[0], options.getProgramArgs());
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        try {
            frontend.buildProgram(options);
        } catch (FileNotFoundException e) {
        // that's what we want
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) RunOptions(org.apache.flink.client.cli.RunOptions) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) FileNotFoundException(java.io.FileNotFoundException) CompilerException(org.apache.flink.optimizer.CompilerException) Test(org.junit.Test)

Example 9 with RunOptions

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

the class CliFrontendPackageProgramTest method testNonExistingFileWithArguments.

@Test
public void testNonExistingFileWithArguments() {
    try {
        String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "/some/none/existing/path", "--debug", "true", "arg1", "arg2" };
        URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") };
        String[] reducedArguments = { "--debug", "true", "arg1", "arg2" };
        RunOptions options = CliFrontendParser.parseRunCommand(arguments);
        assertEquals(arguments[4], options.getJarFilePath());
        assertArrayEquals(classpath, options.getClasspaths().toArray());
        assertArrayEquals(reducedArguments, options.getProgramArgs());
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        try {
            frontend.buildProgram(options);
            fail("Should fail with an exception");
        } catch (FileNotFoundException e) {
        // that's what we want
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL) RunOptions(org.apache.flink.client.cli.RunOptions) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) FileNotFoundException(java.io.FileNotFoundException) CompilerException(org.apache.flink.optimizer.CompilerException) Test(org.junit.Test)

Example 10 with RunOptions

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

the class CliFrontendPackageProgramTest method testVariantWithExplicitJarAndNoArgumentsOption.

@Test
public void testVariantWithExplicitJarAndNoArgumentsOption() {
    try {
        String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "--debug", "true", "arg1", "arg2" };
        URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") };
        String[] reducedArguments = new String[] { "--debug", "true", "arg1", "arg2" };
        RunOptions options = CliFrontendParser.parseRunCommand(arguments);
        assertEquals(getTestJarPath(), options.getJarFilePath());
        assertArrayEquals(classpath, options.getClasspaths().toArray());
        assertArrayEquals(reducedArguments, options.getProgramArgs());
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
        PackagedProgram prog = frontend.buildProgram(options);
        Assert.assertArrayEquals(reducedArguments, prog.getArguments());
        Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : PackagedProgram(org.apache.flink.client.program.PackagedProgram) URL(java.net.URL) RunOptions(org.apache.flink.client.cli.RunOptions) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) FileNotFoundException(java.io.FileNotFoundException) CompilerException(org.apache.flink.optimizer.CompilerException) Test(org.junit.Test)

Aggregations

RunOptions (org.apache.flink.client.cli.RunOptions)23 Test (org.junit.Test)22 File (java.io.File)13 FileNotFoundException (java.io.FileNotFoundException)7 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)6 CompilerException (org.apache.flink.optimizer.CompilerException)6 URL (java.net.URL)5 PackagedProgram (org.apache.flink.client.program.PackagedProgram)5 Configuration (org.apache.flink.configuration.Configuration)5 ClusterClient (org.apache.flink.client.program.ClusterClient)4 InetSocketAddress (java.net.InetSocketAddress)3 CliFrontend (org.apache.flink.client.CliFrontend)3 FlinkYarnSessionCli (org.apache.flink.yarn.cli.FlinkYarnSessionCli)3 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)2 CliArgsException (org.apache.flink.client.cli.CliArgsException)1 DataStatistics (org.apache.flink.optimizer.DataStatistics)1 Optimizer (org.apache.flink.optimizer.Optimizer)1 DefaultCostEstimator (org.apache.flink.optimizer.costs.DefaultCostEstimator)1 CancelJobWithSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.CancelJobWithSavepoint)1 DisposeSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint)1