Search in sources :

Example 16 with FlinkYarnSessionCli

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

the class FlinkYarnSessionCliTest method testResumeFromYarnPropertiesFile.

/**
 * Test that the CliFrontend is able to pick up the .yarn-properties file from a specified
 * location.
 */
@Test
public void testResumeFromYarnPropertiesFile() 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[] {}, true);
    final Configuration executorConfig = flinkYarnSessionCli.toConfiguration(commandLine);
    final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
    final ApplicationId clusterId = clientFactory.getClusterId(executorConfig);
    assertEquals(TEST_YARN_APPLICATION_ID, 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 17 with FlinkYarnSessionCli

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

the class FlinkYarnSessionCliTest method testConfigurationClusterSpecification.

/**
 * Tests that the configuration settings are used to create the {@link ClusterSpecification}.
 */
@Test
public void testConfigurationClusterSpecification() throws Exception {
    final Configuration configuration = new Configuration();
    final int jobManagerMemory = 1337;
    configuration.set(JobManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(jobManagerMemory));
    final int taskManagerMemory = 7331;
    configuration.set(TaskManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(taskManagerMemory));
    final int slotsPerTaskManager = 42;
    configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, slotsPerTaskManager);
    final String[] args = {};
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
    CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false);
    configuration.addAll(flinkYarnSessionCli.toConfiguration(commandLine));
    ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(configuration);
    ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(configuration);
    assertThat(clusterSpecification.getMasterMemoryMB(), is(jobManagerMemory));
    assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(taskManagerMemory));
    assertThat(clusterSpecification.getSlotsPerTaskManager(), is(slotsPerTaskManager));
}
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 18 with FlinkYarnSessionCli

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

the class FlinkYarnSessionCliTest method testCommandLineClusterSpecification.

/**
 * Tests that the command line arguments override the configuration settings when the {@link
 * ClusterSpecification} is created.
 */
@Test
public void testCommandLineClusterSpecification() throws Exception {
    final Configuration configuration = new Configuration();
    final int jobManagerMemory = 1337;
    final int taskManagerMemory = 7331;
    final int slotsPerTaskManager = 30;
    configuration.set(JobManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(jobManagerMemory));
    configuration.set(TaskManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(taskManagerMemory));
    configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, slotsPerTaskManager);
    final String[] args = { "-yjm", String.valueOf(jobManagerMemory) + "m", "-ytm", String.valueOf(taskManagerMemory) + "m", "-ys", String.valueOf(slotsPerTaskManager) };
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
    CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false);
    Configuration executorConfig = flinkYarnSessionCli.toConfiguration(commandLine);
    ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
    ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
    assertThat(clusterSpecification.getMasterMemoryMB(), is(jobManagerMemory));
    assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(taskManagerMemory));
    assertThat(clusterSpecification.getSlotsPerTaskManager(), is(slotsPerTaskManager));
}
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 19 with FlinkYarnSessionCli

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

the class FlinkYarnSessionCliTest method testCorrectSettingOfDetachedMode.

@Test
public void testCorrectSettingOfDetachedMode() throws Exception {
    final String[] params = new String[] { "-yd" };
    FlinkYarnSessionCli yarnCLI = createFlinkYarnSessionCli();
    final CommandLine commandLine = yarnCLI.parseCommandLineOptions(params, true);
    final Configuration executorConfig = yarnCLI.toConfiguration(commandLine);
    assertThat(executorConfig.get(DeploymentOptions.ATTACHED), is(false));
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.flink.configuration.Configuration) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 20 with FlinkYarnSessionCli

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

the class FlinkYarnSessionCliTest method testMemoryPropertyWithoutUnit.

/**
 * Tests the specifying total process memory without unit for job manager and task manager.
 */
@Test
public void testMemoryPropertyWithoutUnit() throws Exception {
    final String[] args = new String[] { "-yjm", "1024", "-ytm", "2048" };
    final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli();
    final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false);
    final Configuration executorConfig = flinkYarnSessionCli.toConfiguration(commandLine);
    final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
    final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
    assertThat(clusterSpecification.getMasterMemoryMB(), is(1024));
    assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(2048));
}
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)

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