Search in sources :

Example 1 with JobManagerRunnerResult

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

the class DispatcherTest method testCancellationOfNonCanceledTerminalJobFailsWithAppropriateException.

@Test
public void testCancellationOfNonCanceledTerminalJobFailsWithAppropriateException() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    }));
    jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
    DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
    JobID jobId = jobGraph.getJobID();
    dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
    jobTerminationFuture.complete(JobManagerRunnerResult.forSuccess(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.FINISHED));
    final CompletableFuture<Acknowledge> cancelFuture = dispatcherGateway.cancelJob(jobId, TIMEOUT);
    assertThat(cancelFuture, FlinkMatchers.futureWillCompleteExceptionally(FlinkJobTerminatedWithoutCancellationException.class, Duration.ofHours(8)));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) FlinkJobTerminatedWithoutCancellationException(org.apache.flink.runtime.messages.FlinkJobTerminatedWithoutCancellationException) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 2 with JobManagerRunnerResult

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

the class DispatcherTest method testCancellationOfCanceledTerminalDoesNotThrowException.

@Test
public void testCancellationOfCanceledTerminalDoesNotThrowException() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    }));
    jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
    DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
    JobID jobId = jobGraph.getJobID();
    dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
    jobTerminationFuture.complete(JobManagerRunnerResult.forSuccess(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.CANCELED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.CANCELED));
    dispatcherGateway.cancelJob(jobId, TIMEOUT).get();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 3 with JobManagerRunnerResult

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

the class CheckpointResourcesCleanupRunnerTest method testResultFutureWithErrorAfterStart.

private static void testResultFutureWithErrorAfterStart(ThrowingConsumer<CheckpointResourcesCleanupRunner, ? extends Exception> preCheckLifecycleHandling) throws Exception {
    final SerializedThrowable expectedError = new SerializedThrowable(new Exception("Expected exception"));
    final CompletableFuture<JobManagerRunnerResult> actualResult = getResultFutureFromTestInstance(createJobResultWithFailure(expectedError), preCheckLifecycleHandling);
    assertThat(actualResult).isCompletedWithValueMatching(jobManagerRunnerResult -> Objects.requireNonNull(jobManagerRunnerResult.getExecutionGraphInfo().getArchivedExecutionGraph().getFailureInfo()).getException().equals(expectedError), "JobManagerRunner should have failed with expected error");
}
Also used : JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) FlinkException(org.apache.flink.util.FlinkException) ExecutionException(java.util.concurrent.ExecutionException) UnavailableDispatcherOperationException(org.apache.flink.runtime.dispatcher.UnavailableDispatcherOperationException) SerializedThrowable(org.apache.flink.util.SerializedThrowable)

Example 4 with JobManagerRunnerResult

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

the class CheckpointResourcesCleanupRunnerTest method testResultFutureWithErrorBeforeStart.

@Test
public void testResultFutureWithErrorBeforeStart() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> resultFuture = getResultFutureFromTestInstance(createJobResultWithFailure(new SerializedThrowable(new Exception("Expected exception"))), BEFORE_START);
    assertThat(resultFuture).isNotCompleted();
}
Also used : JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) FlinkException(org.apache.flink.util.FlinkException) ExecutionException(java.util.concurrent.ExecutionException) UnavailableDispatcherOperationException(org.apache.flink.runtime.dispatcher.UnavailableDispatcherOperationException) SerializedThrowable(org.apache.flink.util.SerializedThrowable) Test(org.junit.jupiter.api.Test)

Example 5 with JobManagerRunnerResult

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

the class DispatcherTest method testNoHistoryServerArchiveCreatedForSuspendedJob.

@Test
public void testNoHistoryServerArchiveCreatedForSuspendedJob() throws Exception {
    final CompletableFuture<Void> archiveAttemptFuture = new CompletableFuture<>();
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createTestingDispatcherBuilder().setJobManagerRunnerFactory(new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    })).setHistoryServerArchivist(executionGraphInfo -> {
        archiveAttemptFuture.complete(null);
        return CompletableFuture.completedFuture(null);
    }).build();
    dispatcher.start();
    jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
    DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
    JobID jobId = jobGraph.getJobID();
    dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
    jobTerminationFuture.complete(JobManagerRunnerResult.forSuccess(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.SUSPENDED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.SUSPENDED));
    assertThat(archiveAttemptFuture.isDone(), is(false));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

JobManagerRunnerResult (org.apache.flink.runtime.jobmaster.JobManagerRunnerResult)5 CompletableFuture (java.util.concurrent.CompletableFuture)3 JobID (org.apache.flink.api.common.JobID)3 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)3 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)3 Test (org.junit.Test)3 ExecutionException (java.util.concurrent.ExecutionException)2 UnavailableDispatcherOperationException (org.apache.flink.runtime.dispatcher.UnavailableDispatcherOperationException)2 FlinkException (org.apache.flink.util.FlinkException)2 SerializedThrowable (org.apache.flink.util.SerializedThrowable)2 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)1 FlinkJobTerminatedWithoutCancellationException (org.apache.flink.runtime.messages.FlinkJobTerminatedWithoutCancellationException)1 Test (org.junit.jupiter.api.Test)1