use of org.apache.flink.runtime.client.DuplicateJobSubmissionException in project flink by apache.
the class DispatcherTest method testDuplicateJobSubmissionWithRunningJobId.
@Test
public void testDuplicateJobSubmissionWithRunningJobId() throws Exception {
dispatcher = createTestingDispatcherBuilder().setJobManagerRunnerFactory(new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch)).setRecoveredJobs(Collections.singleton(jobGraph)).build();
dispatcher.start();
final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final CompletableFuture<Acknowledge> submitFuture = dispatcherGateway.submitJob(jobGraph, TIMEOUT);
final ExecutionException executionException = assertThrows(ExecutionException.class, submitFuture::get);
assertTrue(executionException.getCause() instanceof DuplicateJobSubmissionException);
final DuplicateJobSubmissionException duplicateException = (DuplicateJobSubmissionException) executionException.getCause();
assertFalse(duplicateException.isGloballyTerminated());
}
use of org.apache.flink.runtime.client.DuplicateJobSubmissionException in project flink by apache.
the class SessionDispatcherLeaderProcess method filterOutDuplicateJobSubmissionException.
private Void filterOutDuplicateJobSubmissionException(Throwable throwable) {
final Throwable strippedException = ExceptionUtils.stripCompletionException(throwable);
if (strippedException instanceof DuplicateJobSubmissionException) {
final DuplicateJobSubmissionException duplicateJobSubmissionException = (DuplicateJobSubmissionException) strippedException;
log.debug("Ignore recovered job {} because the job is currently being executed.", duplicateJobSubmissionException.getJobID(), duplicateJobSubmissionException);
return null;
} else {
throw new CompletionException(throwable);
}
}
use of org.apache.flink.runtime.client.DuplicateJobSubmissionException in project flink by apache.
the class ApplicationDispatcherBootstrap method runApplicationEntryPoint.
/**
* Runs the user program entrypoint and completes the given {@code jobIdsFuture} with the {@link
* JobID JobIDs} of the submitted jobs.
*
* <p>This should be executed in a separate thread (or task).
*/
private void runApplicationEntryPoint(final CompletableFuture<List<JobID>> jobIdsFuture, final Set<JobID> tolerateMissingResult, final DispatcherGateway dispatcherGateway, final ScheduledExecutor scheduledExecutor, final boolean enforceSingleJobExecution, final boolean submitFailedJobOnApplicationError) {
if (submitFailedJobOnApplicationError && !enforceSingleJobExecution) {
jobIdsFuture.completeExceptionally(new ApplicationExecutionException(String.format("Submission of failed job in case of an application error ('%s') is not supported in non-HA setups.", DeploymentOptions.SUBMIT_FAILED_JOB_ON_APPLICATION_ERROR.key())));
return;
}
final List<JobID> applicationJobIds = new ArrayList<>(recoveredJobIds);
try {
final PipelineExecutorServiceLoader executorServiceLoader = new EmbeddedExecutorServiceLoader(applicationJobIds, dispatcherGateway, scheduledExecutor);
ClientUtils.executeProgram(executorServiceLoader, configuration, application, enforceSingleJobExecution, true);
if (applicationJobIds.isEmpty()) {
jobIdsFuture.completeExceptionally(new ApplicationExecutionException("The application contains no execute() calls."));
} else {
jobIdsFuture.complete(applicationJobIds);
}
} catch (Throwable t) {
// If we're running in a single job execution mode, it's safe to consider re-submission
// of an already finished a success.
final Optional<DuplicateJobSubmissionException> maybeDuplicate = ExceptionUtils.findThrowable(t, DuplicateJobSubmissionException.class);
if (enforceSingleJobExecution && maybeDuplicate.isPresent() && maybeDuplicate.get().isGloballyTerminated()) {
final JobID jobId = maybeDuplicate.get().getJobID();
tolerateMissingResult.add(jobId);
jobIdsFuture.complete(Collections.singletonList(jobId));
} else if (submitFailedJobOnApplicationError && applicationJobIds.isEmpty()) {
final JobID failedJobId = JobID.fromHexString(configuration.get(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID));
dispatcherGateway.submitFailedJob(failedJobId, FAILED_JOB_NAME, t);
jobIdsFuture.complete(Collections.singletonList(failedJobId));
} else {
jobIdsFuture.completeExceptionally(new ApplicationExecutionException("Could not execute application.", t));
}
}
}
use of org.apache.flink.runtime.client.DuplicateJobSubmissionException in project flink by apache.
the class ApplicationDispatcherBootstrapTest method testDuplicateJobSubmissionWithRunningJobId.
@Test
public void testDuplicateJobSubmissionWithRunningJobId() throws Throwable {
final JobID testJobID = new JobID(0, 2);
final Configuration configurationUnderTest = getConfiguration();
configurationUnderTest.set(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID, testJobID.toHexString());
configurationUnderTest.set(HighAvailabilityOptions.HA_MODE, HighAvailabilityMode.ZOOKEEPER.name());
final TestingDispatcherGateway.Builder dispatcherBuilder = TestingDispatcherGateway.newBuilder().setSubmitFunction(jobGraph -> FutureUtils.completedExceptionally(DuplicateJobSubmissionException.of(testJobID)));
final CompletableFuture<Void> applicationFuture = runApplication(dispatcherBuilder, configurationUnderTest, 1);
final ExecutionException executionException = assertThrows(ExecutionException.class, () -> applicationFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS));
final Optional<DuplicateJobSubmissionException> maybeDuplicate = ExceptionUtils.findThrowable(executionException, DuplicateJobSubmissionException.class);
assertTrue(maybeDuplicate.isPresent());
assertFalse(maybeDuplicate.get().isGloballyTerminated());
}
use of org.apache.flink.runtime.client.DuplicateJobSubmissionException in project flink by apache.
the class DispatcherTest method testDuplicateJobSubmissionWithGloballyTerminatedJobId.
@Test
public void testDuplicateJobSubmissionWithGloballyTerminatedJobId() throws Exception {
final JobResult jobResult = TestingJobResultStore.createJobResult(jobGraph.getJobID(), ApplicationStatus.SUCCEEDED);
haServices.getJobResultStore().createDirtyResult(new JobResultEntry(jobResult));
dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch));
final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final CompletableFuture<Acknowledge> submitFuture = dispatcherGateway.submitJob(jobGraph, TIMEOUT);
final ExecutionException executionException = assertThrows(ExecutionException.class, submitFuture::get);
assertTrue(executionException.getCause() instanceof DuplicateJobSubmissionException);
final DuplicateJobSubmissionException duplicateException = (DuplicateJobSubmissionException) executionException.getCause();
assertTrue(duplicateException.isGloballyTerminated());
}
Aggregations