use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.
the class FlinkYarnSessionCliTest method testMemoryPropertyWithUnitMB.
/**
* Tests the specifying total process memory with unit (MB) for job manager and task manager.
*/
@Test
public void testMemoryPropertyWithUnitMB() throws Exception {
final String[] args = new String[] { "-yjm", "1024m", "-ytm", "2048m" };
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));
}
use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.
the class CliFrontendRunWithYarnTest method testRun.
@Test
public void testRun() throws Exception {
String testJarPath = getTestJarPath("BatchWordCount.jar").getAbsolutePath();
Configuration configuration = new Configuration();
configuration.setString(JobManagerOptions.ADDRESS, "localhost");
configuration.setInteger(JobManagerOptions.PORT, 8081);
configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g"));
final ClusterClientServiceLoader testServiceLoader = new DefaultClusterClientServiceLoader();
final FlinkYarnSessionCli yarnCLI = new FlinkYarnSessionCli(configuration, testServiceLoader, tmp.getRoot().getAbsolutePath(), "y", "yarn", true);
// test detached mode
{
String[] parameters = { "-m", "yarn-cluster", "-p", "2", "-d", testJarPath };
verifyCliFrontend(configuration, testServiceLoader, yarnCLI, parameters, 2, true);
}
// test detached mode
{
String[] parameters = { "-m", "yarn-cluster", "-p", "2", "-yd", testJarPath };
verifyCliFrontend(configuration, testServiceLoader, yarnCLI, parameters, 2, true);
}
}
use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.
the class FlinkYarnSessionCliTest method testNotEnoughTaskSlots.
@Test
public void testNotEnoughTaskSlots() 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", "-p", "7", 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(4, descriptor.getTaskManagerSlots());
Assert.assertEquals(2, descriptor.getTaskManagerCount());
}
use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.
the class FlinkYarnSessionCliTest method testMemoryPropertyWithArbitraryUnit.
/**
* Tests the specifying total process memory with arbitrary unit for job manager and task
* manager.
*/
@Test
public void testMemoryPropertyWithArbitraryUnit() throws Exception {
final String[] args = new String[] { "-yjm", "1g", "-ytm", "2g" };
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));
}
use of org.apache.flink.yarn.cli.FlinkYarnSessionCli in project flink by apache.
the class FlinkYarnSessionCliTest method testNodeLabelProperty.
@Test
public void testNodeLabelProperty() throws Exception {
String nodeLabelCliInput = "flink_test_nodelabel";
String[] params = new String[] { "-ynl", nodeLabelCliInput };
FlinkYarnSessionCli yarnCLI = createFlinkYarnSessionCli();
CommandLine commandLine = yarnCLI.parseCommandLineOptions(params, true);
Configuration executorConfig = yarnCLI.toConfiguration(commandLine);
ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
YarnClusterDescriptor descriptor = (YarnClusterDescriptor) clientFactory.createClusterDescriptor(executorConfig);
assertEquals(nodeLabelCliInput, descriptor.getNodeLabel());
}
Aggregations