Search in sources :

Example 21 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification in project flink by apache.

the class YARNFileReplicationITCase method deployPerJob.

private void deployPerJob(Configuration configuration, JobGraph jobGraph) throws Exception {
    try (final YarnClusterDescriptor yarnClusterDescriptor = createYarnClusterDescriptor(configuration)) {
        yarnClusterDescriptor.setLocalJarPath(new Path(flinkUberjar.getAbsolutePath()));
        yarnClusterDescriptor.addShipFiles(Arrays.asList(flinkLibFolder.listFiles()));
        final int masterMemory = yarnClusterDescriptor.getFlinkConfiguration().get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes();
        final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(masterMemory).setTaskManagerMemoryMB(1024).setSlotsPerTaskManager(1).createClusterSpecification();
        File testingJar = TestUtils.findFile("..", new TestUtils.TestJarFinder("flink-yarn-tests"));
        jobGraph.addJar(new org.apache.flink.core.fs.Path(testingJar.toURI()));
        try (ClusterClient<ApplicationId> clusterClient = yarnClusterDescriptor.deployJobCluster(clusterSpecification, jobGraph, false).getClusterClient()) {
            ApplicationId applicationId = clusterClient.getClusterId();
            extraVerification(configuration, applicationId);
            final CompletableFuture<JobResult> jobResultCompletableFuture = clusterClient.requestJobResult(jobGraph.getJobID());
            final JobResult jobResult = jobResultCompletableFuture.get();
            assertThat(jobResult, is(notNullValue()));
            jobResult.getSerializedThrowable().ifPresent(serializedThrowable -> {
                throw new AssertionError("Job failed", serializedThrowable.deserializeError(YARNFileReplicationITCase.class.getClassLoader()));
            });
            waitApplicationFinishedElseKillIt(applicationId, yarnAppTerminateTimeout, yarnClusterDescriptor, sleepIntervalInMS);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) JobResult(org.apache.flink.runtime.jobmaster.JobResult) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) TestUtils(org.apache.flink.yarn.util.TestUtils) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) File(java.io.File)

Example 22 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification in project flink by apache.

the class YARNITCase method deployPerJob.

private void deployPerJob(Configuration configuration, JobGraph jobGraph, boolean withDist) throws Exception {
    jobGraph.setJobType(JobType.STREAMING);
    try (final YarnClusterDescriptor yarnClusterDescriptor = withDist ? createYarnClusterDescriptor(configuration) : createYarnClusterDescriptorWithoutLibDir(configuration)) {
        final int masterMemory = yarnClusterDescriptor.getFlinkConfiguration().get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes();
        final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(masterMemory).setTaskManagerMemoryMB(1024).setSlotsPerTaskManager(1).createClusterSpecification();
        File testingJar = TestUtils.findFile("..", new TestUtils.TestJarFinder("flink-yarn-tests"));
        jobGraph.addJar(new org.apache.flink.core.fs.Path(testingJar.toURI()));
        try (ClusterClient<ApplicationId> clusterClient = yarnClusterDescriptor.deployJobCluster(clusterSpecification, jobGraph, false).getClusterClient()) {
            for (DistributedCache.DistributedCacheEntry entry : jobGraph.getUserArtifacts().values()) {
                assertTrue(String.format("The user artifacts(%s) should be remote or uploaded to remote filesystem.", entry.filePath), Utils.isRemotePath(entry.filePath));
            }
            ApplicationId applicationId = clusterClient.getClusterId();
            final CompletableFuture<JobResult> jobResultCompletableFuture = clusterClient.requestJobResult(jobGraph.getJobID());
            final JobResult jobResult = jobResultCompletableFuture.get();
            assertThat(jobResult, is(notNullValue()));
            assertThat(jobResult.getSerializedThrowable().isPresent(), is(false));
            checkStagingDirectory(configuration, applicationId);
            waitApplicationFinishedElseKillIt(applicationId, yarnAppTerminateTimeout, yarnClusterDescriptor, sleepIntervalInMS);
        }
    }
}
Also used : JobResult(org.apache.flink.runtime.jobmaster.JobResult) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) TestUtils(org.apache.flink.yarn.util.TestUtils) DistributedCache(org.apache.flink.api.common.cache.DistributedCache) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) File(java.io.File)

Example 23 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification in project flink by apache.

the class YARNApplicationITCase method deployApplication.

private void deployApplication(Configuration configuration) throws Exception {
    try (final YarnClusterDescriptor yarnClusterDescriptor = createYarnClusterDescriptor(configuration)) {
        final int masterMemory = yarnClusterDescriptor.getFlinkConfiguration().get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes();
        final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(masterMemory).setTaskManagerMemoryMB(1024).setSlotsPerTaskManager(1).createClusterSpecification();
        try (ClusterClient<ApplicationId> clusterClient = yarnClusterDescriptor.deployApplicationCluster(clusterSpecification, ApplicationConfiguration.fromConfiguration(configuration)).getClusterClient()) {
            ApplicationId applicationId = clusterClient.getClusterId();
            waitApplicationFinishedElseKillIt(applicationId, yarnAppTerminateTimeout, yarnClusterDescriptor, sleepIntervalInMS);
        }
    }
}
Also used : ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 24 with ClusterSpecification

use of org.apache.flink.client.deployment.ClusterSpecification in project flink by apache.

the class YarnClusterDescriptorTest method testConfigOverwrite.

@Test
public void testConfigOverwrite() throws ClusterDeploymentException {
    Configuration configuration = new Configuration();
    // overwrite vcores in config
    configuration.setInteger(YarnConfigOptions.VCORES, Integer.MAX_VALUE);
    YarnClusterDescriptor clusterDescriptor = createYarnClusterDescriptor(configuration);
    clusterDescriptor.setLocalJarPath(new Path(flinkJar.getPath()));
    // configure slots
    ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().createClusterSpecification();
    try {
        clusterDescriptor.deploySessionCluster(clusterSpecification);
        fail("The deploy call should have failed.");
    } catch (ClusterDeploymentException e) {
        // we expect the cause to be an IllegalConfigurationException
        if (!(e.getCause() instanceof IllegalConfigurationException)) {
            throw e;
        }
    } finally {
        clusterDescriptor.close();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.flink.configuration.Configuration) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Example 25 with ClusterSpecification

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