Search in sources :

Example 1 with DuplicateJobSubmissionException

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());
}
Also used : Acknowledge(org.apache.flink.runtime.messages.Acknowledge) ExecutionException(java.util.concurrent.ExecutionException) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException) Test(org.junit.Test)

Example 2 with DuplicateJobSubmissionException

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);
    }
}
Also used : CompletionException(java.util.concurrent.CompletionException) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException)

Example 3 with DuplicateJobSubmissionException

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));
        }
    }
}
Also used : PipelineExecutorServiceLoader(org.apache.flink.core.execution.PipelineExecutorServiceLoader) EmbeddedExecutorServiceLoader(org.apache.flink.client.deployment.application.executors.EmbeddedExecutorServiceLoader) Optional(java.util.Optional) ArrayList(java.util.ArrayList) JobID(org.apache.flink.api.common.JobID) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException)

Example 4 with DuplicateJobSubmissionException

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());
}
Also used : TestingDispatcherGateway(org.apache.flink.runtime.webmonitor.TestingDispatcherGateway) Configuration(org.apache.flink.configuration.Configuration) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) ExecutionException(java.util.concurrent.ExecutionException) JobID(org.apache.flink.api.common.JobID) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with DuplicateJobSubmissionException

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());
}
Also used : JobResult(org.apache.flink.runtime.jobmaster.JobResult) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) JobResultEntry(org.apache.flink.runtime.highavailability.JobResultEntry) ExecutionException(java.util.concurrent.ExecutionException) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException) Test(org.junit.Test)

Aggregations

DuplicateJobSubmissionException (org.apache.flink.runtime.client.DuplicateJobSubmissionException)5 ExecutionException (java.util.concurrent.ExecutionException)3 JobID (org.apache.flink.api.common.JobID)2 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 CompletionException (java.util.concurrent.CompletionException)1 EmbeddedExecutorServiceLoader (org.apache.flink.client.deployment.application.executors.EmbeddedExecutorServiceLoader)1 Configuration (org.apache.flink.configuration.Configuration)1 PipelineExecutorServiceLoader (org.apache.flink.core.execution.PipelineExecutorServiceLoader)1 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)1 JobResultEntry (org.apache.flink.runtime.highavailability.JobResultEntry)1 JobResult (org.apache.flink.runtime.jobmaster.JobResult)1 TestingDispatcherGateway (org.apache.flink.runtime.webmonitor.TestingDispatcherGateway)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1