Search in sources :

Example 11 with JobResult

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

the class JobStatusPollingUtilsTest method testFailedJobResult.

@Test
public void testFailedJobResult() throws ExecutionException, InterruptedException {
    final int maxAttemptCounter = 1;
    final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
    try {
        final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(executor);
        final CallCountingJobStatusSupplier jobStatusSupplier = new CallCountingJobStatusSupplier(maxAttemptCounter);
        final CompletableFuture<JobResult> result = JobStatusPollingUtils.pollJobResultAsync(jobStatusSupplier, () -> CompletableFuture.completedFuture(createFailedJobResult(new JobID(0, 0))), scheduledExecutor, 10);
        result.join();
        assertThat(jobStatusSupplier.getAttemptCounter(), is(equalTo(maxAttemptCounter)));
        assertTrue(result.isDone() && result.get().getSerializedThrowable().isPresent());
    } finally {
        ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor);
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledExecutorServiceAdapter(org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter) JobResult(org.apache.flink.runtime.jobmaster.JobResult) JobID(org.apache.flink.api.common.JobID) ScheduledExecutor(org.apache.flink.util.concurrent.ScheduledExecutor) Test(org.junit.Test)

Example 12 with JobResult

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

the class LeaderChangeClusterComponentsTest method testReelectionOfJobMaster.

@Test
public void testReelectionOfJobMaster() throws Exception {
    final CompletableFuture<JobSubmissionResult> submissionFuture = miniCluster.submitJob(jobGraph);
    submissionFuture.get();
    CompletableFuture<JobResult> jobResultFuture = miniCluster.requestJobResult(jobId);
    // need to wait until init is finished, so that the leadership revocation is possible
    CommonTestUtils.waitUntilJobManagerIsInitialized(() -> miniCluster.getJobStatus(jobId).get());
    highAvailabilityServices.revokeJobMasterLeadership(jobId).get();
    JobResultUtils.assertIncomplete(jobResultFuture);
    BlockingOperator.isBlocking = false;
    highAvailabilityServices.grantJobMasterLeadership(jobId);
    JobResult jobResult = jobResultFuture.get();
    JobResultUtils.assertSuccess(jobResult);
}
Also used : JobSubmissionResult(org.apache.flink.api.common.JobSubmissionResult) JobResult(org.apache.flink.runtime.jobmaster.JobResult) Test(org.junit.Test)

Example 13 with JobResult

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

the class TaskExecutorITCase method testJobReExecutionAfterTaskExecutorTermination.

/**
 * Tests that a job can be re-executed after the job has failed due to a TaskExecutor
 * termination.
 */
@Test
public void testJobReExecutionAfterTaskExecutorTermination() throws Exception {
    final JobGraph jobGraph = createJobGraph(PARALLELISM);
    final CompletableFuture<JobResult> jobResultFuture = submitJobAndWaitUntilRunning(jobGraph);
    // kill one TaskExecutor which should fail the job execution
    miniCluster.terminateTaskManager(0);
    final JobResult jobResult = jobResultFuture.get();
    assertThat(jobResult.isSuccess(), is(false));
    miniCluster.startTaskManager();
    final JobGraph newJobGraph = createJobGraph(PARALLELISM);
    BlockingOperator.unblock();
    miniCluster.submitJob(newJobGraph).get();
    miniCluster.requestJobResult(newJobGraph.getJobID()).get();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) Test(org.junit.Test)

Example 14 with JobResult

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

the class TaskExecutorITCase method testJobRecoveryWithFailingTaskExecutor.

/**
 * Tests that the job can recover from a failing {@link TaskExecutor}.
 */
@Test
public void testJobRecoveryWithFailingTaskExecutor() throws Exception {
    final JobGraph jobGraph = createJobGraphWithRestartStrategy(PARALLELISM);
    final CompletableFuture<JobResult> jobResultFuture = submitJobAndWaitUntilRunning(jobGraph);
    // start an additional TaskExecutor
    miniCluster.startTaskManager();
    // this should fail the job
    miniCluster.terminateTaskManager(0).get();
    BlockingOperator.unblock();
    assertThat(jobResultFuture.get().isSuccess(), is(true));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) Test(org.junit.Test)

Example 15 with JobResult

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

the class NetworkStackThroughputITCase method testProgram.

private void testProgram(final MiniClusterWithClientResource cluster, final int dataVolumeGb, final boolean useForwarder, final boolean isSlowSender, final boolean isSlowReceiver, final int parallelism) throws Exception {
    final ClusterClient<?> client = cluster.getClusterClient();
    final JobGraph jobGraph = createJobGraph(dataVolumeGb, useForwarder, isSlowSender, isSlowReceiver, parallelism);
    final JobResult jobResult = client.submitJob(jobGraph).thenCompose(client::requestJobResult).get();
    Assert.assertFalse(jobResult.getSerializedThrowable().isPresent());
    final long dataVolumeMbit = dataVolumeGb * 8192;
    final long runtimeSecs = TimeUnit.SECONDS.convert(jobResult.getNetRuntime(), TimeUnit.MILLISECONDS);
    final int mbitPerSecond = (int) (((double) dataVolumeMbit) / runtimeSecs);
    LOG.info(String.format("Test finished with throughput of %d MBit/s (runtime [secs]: %d, " + "data volume [gb/mbits]: %d/%d)", mbitPerSecond, runtimeSecs, dataVolumeGb, dataVolumeMbit));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult)

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