Search in sources :

Example 21 with JobResult

use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.

the class JobResultDeserializerTest method testDeserialization.

@Test
public void testDeserialization() throws Exception {
    final JobResult jobResult = objectMapper.readValue("{\n" + "\t\"id\": \"1bb5e8c7df49938733b7c6a73678de6a\",\n" + "\t\"accumulator-results\": {},\n" + "\t\"net-runtime\": 0,\n" + "\t\"unknownfield\": \"foobar\"\n" + "}", JobResult.class);
    assertThat(jobResult.getJobId(), equalTo(JobID.fromHexString("1bb5e8c7df49938733b7c6a73678de6a")));
    assertThat(jobResult.getNetRuntime(), equalTo(0L));
    assertThat(jobResult.getAccumulatorResults().size(), equalTo(0));
    assertThat(jobResult.getSerializedThrowable().isPresent(), equalTo(false));
}
Also used : JobResult(org.apache.flink.runtime.jobmaster.JobResult) Test(org.junit.Test)

Example 22 with JobResult

use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.

the class BlobsCleanupITCase method testBlobServerCleanup.

private void testBlobServerCleanup(final TestCase testCase) throws Exception {
    final MiniCluster miniCluster = miniClusterResource.getMiniCluster();
    final int numTasks = 2;
    final Deadline timeout = Deadline.fromNow(Duration.ofSeconds(30L));
    final JobGraph jobGraph = createJobGraph(testCase, numTasks);
    final JobID jid = jobGraph.getJobID();
    // upload a blob
    final File tempBlob = File.createTempFile("Required", ".jar");
    final int blobPort = miniCluster.getClusterInformation().getBlobServerPort();
    List<PermanentBlobKey> keys = BlobClient.uploadFiles(new InetSocketAddress("localhost", blobPort), configuration, jid, Collections.singletonList(new Path(tempBlob.getAbsolutePath())));
    assertThat(keys, hasSize(1));
    jobGraph.addUserJarBlobKey(keys.get(0));
    if (testCase == TestCase.JOB_SUBMISSION_FAILS) {
        // add an invalid key so that the submission fails
        jobGraph.addUserJarBlobKey(new PermanentBlobKey());
    }
    final CompletableFuture<JobSubmissionResult> submissionFuture = miniCluster.submitJob(jobGraph);
    if (testCase == TestCase.JOB_SUBMISSION_FAILS) {
        try {
            submissionFuture.get();
            fail("Expected job submission failure.");
        } catch (ExecutionException e) {
            assertThat(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent(), is(true));
        }
    } else {
        final JobSubmissionResult jobSubmissionResult = submissionFuture.get();
        assertThat(jobSubmissionResult.getJobID(), is(jid));
        final CompletableFuture<JobResult> resultFuture = miniCluster.requestJobResult(jid);
        if (testCase == TestCase.JOB_FAILS) {
            // fail a task so that the job is going to be recovered (we actually do not
            // need the blocking part of the invokable and can start throwing right away)
            FailingBlockingInvokable.unblock();
            // job will get restarted, BlobCache may re-download the BLOB if already deleted
            // then the tasks will fail again and the restart strategy will finalise the job
            final JobResult jobResult = resultFuture.get();
            assertThat(jobResult.isSuccess(), is(false));
            assertThat(jobResult.getApplicationStatus(), is(ApplicationStatus.FAILED));
        } else if (testCase == TestCase.JOB_IS_CANCELLED) {
            miniCluster.cancelJob(jid);
            final JobResult jobResult = resultFuture.get();
            assertThat(jobResult.isSuccess(), is(false));
            assertThat(jobResult.getApplicationStatus(), is(ApplicationStatus.CANCELED));
        } else {
            final JobResult jobResult = resultFuture.get();
            Throwable cause = jobResult.getSerializedThrowable().map(throwable -> throwable.deserializeError(getClass().getClassLoader())).orElse(null);
            assertThat(ExceptionUtils.stringifyException(cause), jobResult.isSuccess(), is(true));
        }
    }
    // both BlobServer and BlobCache should eventually delete all files
    File[] blobDirs = blobBaseDir.listFiles((dir, name) -> name.startsWith("blobStore-"));
    assertNotNull(blobDirs);
    for (File blobDir : blobDirs) {
        waitForEmptyBlobDir(blobDir, timeout.timeLeft());
    }
}
Also used : Path(org.apache.flink.core.fs.Path) JobResult(org.apache.flink.runtime.jobmaster.JobResult) InetSocketAddress(java.net.InetSocketAddress) Deadline(org.apache.flink.api.common.time.Deadline) JobSubmissionException(org.apache.flink.runtime.client.JobSubmissionException) JobSubmissionResult(org.apache.flink.api.common.JobSubmissionResult) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) PermanentBlobKey(org.apache.flink.runtime.blob.PermanentBlobKey) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File) JobID(org.apache.flink.api.common.JobID)

Example 23 with JobResult

use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.

the class AdaptiveSchedulerClusterITCase method testAutomaticScaleDownInCaseOfLostSlots.

@Test
public void testAutomaticScaleDownInCaseOfLostSlots() throws Exception {
    final MiniCluster miniCluster = miniClusterResource.getMiniCluster();
    final JobGraph jobGraph = createBlockingJobGraph(PARALLELISM);
    miniCluster.submitJob(jobGraph).join();
    final CompletableFuture<JobResult> resultFuture = miniCluster.requestJobResult(jobGraph.getJobID());
    waitUntilParallelismForVertexReached(jobGraph.getJobID(), JOB_VERTEX_ID, NUMBER_SLOTS_PER_TASK_MANAGER * NUMBER_TASK_MANAGERS);
    miniCluster.terminateTaskManager(0);
    waitUntilParallelismForVertexReached(jobGraph.getJobID(), JOB_VERTEX_ID, NUMBER_SLOTS_PER_TASK_MANAGER * (NUMBER_TASK_MANAGERS - 1));
    OnceBlockingNoOpInvokable.unblock();
    final JobResult jobResult = resultFuture.join();
    assertTrue(jobResult.isSuccess());
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Test(org.junit.Test)

Example 24 with JobResult

use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.

the class AdaptiveSchedulerSimpleITCase method testGlobalFailoverIfTaskFails.

@Test
public void testGlobalFailoverIfTaskFails() throws Throwable {
    final MiniCluster miniCluster = MINI_CLUSTER_RESOURCE.getMiniCluster();
    final JobGraph jobGraph = createOnceFailingJobGraph();
    miniCluster.submitJob(jobGraph).join();
    final JobResult jobResult = miniCluster.requestJobResult(jobGraph.getJobID()).join();
    if (!jobResult.isSuccess()) {
        throw jobResult.getSerializedThrowable().get().deserializeError(ClassLoader.getSystemClassLoader());
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Test(org.junit.Test)

Example 25 with JobResult

use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.

the class AdaptiveSchedulerSimpleITCase method testSchedulingOfSimpleJob.

@Test
public void testSchedulingOfSimpleJob() throws Exception {
    final MiniCluster miniCluster = MINI_CLUSTER_RESOURCE.getMiniCluster();
    final JobGraph jobGraph = createJobGraph();
    miniCluster.submitJob(jobGraph).join();
    final JobResult jobResult = miniCluster.requestJobResult(jobGraph.getJobID()).join();
    final JobExecutionResult jobExecutionResult = jobResult.toJobExecutionResult(getClass().getClassLoader());
    assertTrue(jobResult.isSuccess());
}
Also used : JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Test(org.junit.Test)

Aggregations

JobResult (org.apache.flink.runtime.jobmaster.JobResult)58 Test (org.junit.Test)28 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)25 JobID (org.apache.flink.api.common.JobID)15 Test (org.junit.jupiter.api.Test)13 MiniCluster (org.apache.flink.runtime.minicluster.MiniCluster)11 ExecutionException (java.util.concurrent.ExecutionException)8 JobSubmissionResult (org.apache.flink.api.common.JobSubmissionResult)7 Deadline (org.apache.flink.api.common.time.Deadline)7 Configuration (org.apache.flink.configuration.Configuration)7 File (java.io.File)5 JobResultStore (org.apache.flink.runtime.highavailability.JobResultStore)5 IOException (java.io.IOException)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)4 Duration (java.time.Duration)3 List (java.util.List)3 Time (org.apache.flink.api.common.time.Time)3 MiniClusterClient (org.apache.flink.client.program.MiniClusterClient)3