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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations