Search in sources :

Example 1 with FlinkYarnSessionCli

use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.

the class FlinkYarnSessionCliTest method testJobManagerMemoryPropertyWithConfigDefaultValue.

/**
 * Tests the specifying job manager total process memory with config default value for job
 * manager and task manager.
 */
@Test
public void testJobManagerMemoryPropertyWithConfigDefaultValue() throws Exception {
    int procMemory = 2048;
    final Configuration configuration = createConfigurationWithJmAndTmTotalMemory(procMemory);
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
    final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[0], false);
    configuration.addAll(flinkYarnSessionCli.toConfiguration(commandLine));
    final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(configuration);
    final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(configuration);
    assertThat(clusterSpecification.getMasterMemoryMB(), is(procMemory));
    assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(procMemory));
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.flink.configuration.Configuration) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 2 with FlinkYarnSessionCli

use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.

the class FlinkYarnSessionCliTest method testYarnIDOverridesPropertiesFile.

@Test
public void testYarnIDOverridesPropertiesFile() throws Exception {
    File directoryPath = writeYarnPropertiesFile(validPropertiesFile);
    final Configuration configuration = new Configuration();
    configuration.setString(YarnConfigOptions.PROPERTIES_FILE_LOCATION, directoryPath.getAbsolutePath());
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
    final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] { "-yid", TEST_YARN_APPLICATION_ID_2.toString() }, true);
    final Configuration executorConfig = flinkYarnSessionCli.toConfiguration(commandLine);
    final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
    final ApplicationId clusterId = clientFactory.getClusterId(executorConfig);
    assertEquals(TEST_YARN_APPLICATION_ID_2, clusterId);
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.flink.configuration.Configuration) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) File(java.io.File) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 3 with FlinkYarnSessionCli

use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.

the class FlinkYarnSessionCliTest method testMultipleYarnShipOptions.

@Test
public void testMultipleYarnShipOptions() throws Exception {
    final String[] args = new String[] { "run", "--yarnship", tmp.newFolder().getAbsolutePath(), "--yarnship", tmp.newFolder().getAbsolutePath() };
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli();
    final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false);
    final Configuration executorConfig = flinkYarnSessionCli.toConfiguration(commandLine);
    final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
    YarnClusterDescriptor flinkYarnDescriptor = (YarnClusterDescriptor) clientFactory.createClusterDescriptor(executorConfig);
    assertEquals(2, flinkYarnDescriptor.getShipFiles().size());
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.flink.configuration.Configuration) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 4 with FlinkYarnSessionCli

use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.

the class FlinkYarnSessionCliTest method validateYarnCLIisActive.

private void validateYarnCLIisActive(Configuration configuration) throws FlinkException, CliArgsException {
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
    final CommandLine testCLIArgs = flinkYarnSessionCli.parseCommandLineOptions(new String[] {}, true);
    assertTrue(flinkYarnSessionCli.isActive(testCLIArgs));
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli)

Example 5 with FlinkYarnSessionCli

use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.

the class FlinkYarnSessionCliTest method testDynamicProperties.

@Test
public void testDynamicProperties() throws Exception {
    FlinkYarnSessionCli cli = new FlinkYarnSessionCli(new Configuration(), tmp.getRoot().getAbsolutePath(), "", "", false);
    Options options = new Options();
    cli.addGeneralOptions(options);
    cli.addRunOptions(options);
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, new String[] { "run", "-j", "fake.jar", "-D", AkkaOptions.ASK_TIMEOUT_DURATION.key() + "=5 min", "-D", CoreOptions.FLINK_JVM_OPTIONS.key() + "=-DappName=foobar", "-D", SecurityOptions.SSL_INTERNAL_KEY_PASSWORD.key() + "=changeit" });
    Configuration executorConfig = cli.toConfiguration(cmd);
    assertEquals(Duration.ofMinutes(5), executorConfig.get(AkkaOptions.ASK_TIMEOUT_DURATION));
    assertEquals("-DappName=foobar", executorConfig.get(CoreOptions.FLINK_JVM_OPTIONS));
    assertEquals("changeit", executorConfig.get(SecurityOptions.SSL_INTERNAL_KEY_PASSWORD));
}
Also used : SecurityOptions(org.apache.flink.configuration.SecurityOptions) Options(org.apache.commons.cli.Options) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) DeploymentOptions(org.apache.flink.configuration.DeploymentOptions) AkkaOptions(org.apache.flink.configuration.AkkaOptions) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) YarnConfigOptions(org.apache.flink.yarn.configuration.YarnConfigOptions) CoreOptions(org.apache.flink.configuration.CoreOptions) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.flink.configuration.Configuration) CommandLineParser(org.apache.commons.cli.CommandLineParser) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) DefaultParser(org.apache.commons.cli.DefaultParser) Test(org.junit.Test)

Aggregations

FlinkYarnSessionCli (org.apache.flink.yarn.cli.FlinkYarnSessionCli)23 Test (org.junit.Test)22 CommandLine (org.apache.commons.cli.CommandLine)21 CustomCommandLine (org.apache.flink.client.cli.CustomCommandLine)21 Configuration (org.apache.flink.configuration.Configuration)20 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)16 ClusterSpecification (org.apache.flink.client.deployment.ClusterSpecification)8 File (java.io.File)5 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 CliFrontend (org.apache.flink.client.CliFrontend)1 RunOptions (org.apache.flink.client.cli.RunOptions)1 ClusterClientServiceLoader (org.apache.flink.client.deployment.ClusterClientServiceLoader)1 DefaultClusterClientServiceLoader (org.apache.flink.client.deployment.DefaultClusterClientServiceLoader)1 AkkaOptions (org.apache.flink.configuration.AkkaOptions)1 CoreOptions (org.apache.flink.configuration.CoreOptions)1 DeploymentOptions (org.apache.flink.configuration.DeploymentOptions)1 HighAvailabilityOptions (org.apache.flink.configuration.HighAvailabilityOptions)1 JobManagerOptions (org.apache.flink.configuration.JobManagerOptions)1