Search in sources :

Example 26 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification 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 27 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification 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 28 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification 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

ClusterSpecification (org.apache.flink.client.deployment.ClusterSpecification)28 Configuration (org.apache.flink.configuration.Configuration)20 Test (org.junit.Test)17 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)15 CommandLine (org.apache.commons.cli.CommandLine)9 CustomCommandLine (org.apache.flink.client.cli.CustomCommandLine)8 FlinkYarnSessionCli (org.apache.flink.yarn.cli.FlinkYarnSessionCli)8 File (java.io.File)5 ClusterDeploymentException (org.apache.flink.client.deployment.ClusterDeploymentException)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)4 FlinkException (org.apache.flink.util.FlinkException)4 Path (org.apache.hadoop.fs.Path)4 IOException (java.io.IOException)3 ClusterRetrieveException (org.apache.flink.client.deployment.ClusterRetrieveException)3 ApplicationConfiguration (org.apache.flink.client.deployment.application.ApplicationConfiguration)3 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)3 KubernetesJobManagerParameters (org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)3 ClusterEntrypoint (org.apache.flink.runtime.entrypoint.ClusterEntrypoint)3 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3