org.apache.flink.runtime.client.JobSubmissionException Java Examples

The following examples show how to use org.apache.flink.runtime.client.JobSubmissionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Dispatcher.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<Acknowledge> internalSubmitJob(JobGraph jobGraph) {
	log.info("Submitting job {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	final CompletableFuture<Acknowledge> persistAndRunFuture = waitForTerminatingJobManager(jobGraph.getJobID(), jobGraph, this::persistAndRunJob)
		.thenApply(ignored -> Acknowledge.get());

	return persistAndRunFuture.handleAsync((acknowledge, throwable) -> {
		if (throwable != null) {
			cleanUpJobData(jobGraph.getJobID(), true);

			final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
			log.error("Failed to submit job {}.", jobGraph.getJobID(), strippedThrowable);
			throw new CompletionException(
				new JobSubmissionException(jobGraph.getJobID(), "Failed to submit job.", strippedThrowable));
		} else {
			return acknowledge;
		}
	}, getRpcService().getExecutor());
}
 
Example #2
Source File: DispatcherResourceCleanupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a duplicate job submission won't delete any job meta data
 * (submitted job graphs, blobs, etc.).
 */
@Test
public void testDuplicateJobSubmissionDoesNotDeleteJobMetaData() throws Exception {
	submitJob();

	final CompletableFuture<Acknowledge> submissionFuture = dispatcherGateway.submitJob(jobGraph, timeout);

	try {
		try {
			submissionFuture.get();
			fail("Expected a JobSubmissionFailure.");
		} catch (ExecutionException ee) {
			assertThat(ExceptionUtils.findThrowable(ee, JobSubmissionException.class).isPresent(), is(true));
		}

		assertThatHABlobsHaveNotBeenRemoved();
	} finally {
		finishJob();
	}

	assertThatHABlobsHaveBeenRemoved();
}
 
Example #3
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> submitJob(JobGraph jobGraph, Time timeout) {
	log.info("Received JobGraph submission {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	try {
		if (isDuplicateJob(jobGraph.getJobID())) {
			return FutureUtils.completedExceptionally(
				new JobSubmissionException(jobGraph.getJobID(), "Job has already been submitted."));
		} else if (isPartialResourceConfigured(jobGraph)) {
			return FutureUtils.completedExceptionally(
				new JobSubmissionException(jobGraph.getJobID(), "Currently jobs is not supported if parts of the vertices have " +
						"resources configured. The limitation will be removed in future versions."));
		} else {
			return internalSubmitJob(jobGraph);
		}
	} catch (FlinkException e) {
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #4
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<Acknowledge> internalSubmitJob(JobGraph jobGraph) {
	log.info("Submitting job {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	final CompletableFuture<Acknowledge> persistAndRunFuture = waitForTerminatingJobManager(jobGraph.getJobID(), jobGraph, this::persistAndRunJob)
		.thenApply(ignored -> Acknowledge.get());

	return persistAndRunFuture.handleAsync((acknowledge, throwable) -> {
		if (throwable != null) {
			cleanUpJobData(jobGraph.getJobID(), true);

			final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
			log.error("Failed to submit job {}.", jobGraph.getJobID(), strippedThrowable);
			throw new CompletionException(
				new JobSubmissionException(jobGraph.getJobID(), "Failed to submit job.", strippedThrowable));
		} else {
			return acknowledge;
		}
	}, getRpcService().getExecutor());
}
 
Example #5
Source File: DispatcherResourceCleanupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a duplicate job submission won't delete any job meta data
 * (submitted job graphs, blobs, etc.).
 */
@Test
public void testDuplicateJobSubmissionDoesNotDeleteJobMetaData() throws Exception {
	submitJob();

	final CompletableFuture<Acknowledge> submissionFuture = dispatcherGateway.submitJob(jobGraph, timeout);

	try {
		try {
			submissionFuture.get();
			fail("Expected a JobSubmissionFailure.");
		} catch (ExecutionException ee) {
			assertThat(ExceptionUtils.findThrowable(ee, JobSubmissionException.class).isPresent(), is(true));
		}

		assertThatHABlobsHaveNotBeenRemoved();
	} finally {
		finishJob();
	}

	assertThatHABlobsHaveBeenRemoved();
}
 
Example #6
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> submitJob(JobGraph jobGraph, Time timeout) {
	log.info("Received JobGraph submission {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	try {
		if (isDuplicateJob(jobGraph.getJobID())) {
			return FutureUtils.completedExceptionally(
				new DuplicateJobSubmissionException(jobGraph.getJobID()));
		} else if (isPartialResourceConfigured(jobGraph)) {
			return FutureUtils.completedExceptionally(
				new JobSubmissionException(jobGraph.getJobID(), "Currently jobs is not supported if parts of the vertices have " +
						"resources configured. The limitation will be removed in future versions."));
		} else {
			return internalSubmitJob(jobGraph);
		}
	} catch (FlinkException e) {
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #7
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<Acknowledge> internalSubmitJob(JobGraph jobGraph) {
	log.info("Submitting job {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	final CompletableFuture<Acknowledge> persistAndRunFuture = waitForTerminatingJobManager(jobGraph.getJobID(), jobGraph, this::persistAndRunJob)
		.thenApply(ignored -> Acknowledge.get());

	return persistAndRunFuture.handleAsync((acknowledge, throwable) -> {
		if (throwable != null) {
			cleanUpJobData(jobGraph.getJobID(), true);

			final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
			log.error("Failed to submit job {}.", jobGraph.getJobID(), strippedThrowable);
			throw new CompletionException(
				new JobSubmissionException(jobGraph.getJobID(), "Failed to submit job.", strippedThrowable));
		} else {
			return acknowledge;
		}
	}, getRpcService().getExecutor());
}
 
Example #8
Source File: Dispatcher.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> submitJob(JobGraph jobGraph, Time timeout) {
	log.info("Received JobGraph submission {} ({}).", jobGraph.getJobID(), jobGraph.getName());

	try {
		if (isDuplicateJob(jobGraph.getJobID())) {
			return FutureUtils.completedExceptionally(
				new JobSubmissionException(jobGraph.getJobID(), "Job has already been submitted."));
		} else {
			return internalSubmitJob(jobGraph);
		}
	} catch (FlinkException e) {
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #9
Source File: DispatcherResourceCleanupTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the uploaded blobs are being cleaned up in case of a job submission failure.
 */
@Test
public void testBlobServerCleanupWhenJobSubmissionFails() throws Exception {
	failJobMasterCreationWith.set(() -> new FlinkException("Test exception."));
	final CompletableFuture<Acknowledge> submissionFuture = dispatcherGateway.submitJob(jobGraph, timeout);

	try {
		submissionFuture.get();
		fail("Job submission was expected to fail.");
	} catch (ExecutionException ee) {
		assertThat(ExceptionUtils.findThrowable(ee, JobSubmissionException.class).isPresent(), is(true));
	}

	assertThatHABlobsHaveBeenRemoved();
}
 
Example #10
Source File: DispatcherResourceCleanupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the uploaded blobs are being cleaned up in case of a job submission failure.
 */
@Test
public void testBlobServerCleanupWhenJobSubmissionFails() throws Exception {
	failJobMasterCreationWith.set(() -> new FlinkException("Test exception."));
	final CompletableFuture<Acknowledge> submissionFuture = dispatcherGateway.submitJob(jobGraph, timeout);

	try {
		submissionFuture.get();
		fail("Job submission was expected to fail.");
	} catch (ExecutionException ee) {
		assertThat(ExceptionUtils.findThrowable(ee, JobSubmissionException.class).isPresent(), is(true));
	}

	assertThatHABlobsHaveBeenRemoved();
}
 
Example #11
Source File: DispatcherTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that we can submit a job to the Dispatcher which then spawns a
 * new JobManagerRunner.
 */
@Test
public void testJobSubmissionWithPartialResourceConfigured() throws Exception {
	dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch));

	CompletableFuture<UUID> leaderFuture = dispatcherLeaderElectionService.isLeader(UUID.randomUUID());

	// wait for the leader to be elected
	leaderFuture.get();

	DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);

	ResourceSpec resourceSpec = ResourceSpec.newBuilder().setCpuCores(2).build();

	final JobVertex firstVertex = new JobVertex("firstVertex");
	firstVertex.setInvokableClass(NoOpInvokable.class);
	firstVertex.setResources(resourceSpec, resourceSpec);

	final JobVertex secondVertex = new JobVertex("secondVertex");
	secondVertex.setInvokableClass(NoOpInvokable.class);

	JobGraph jobGraphWithTwoVertices = new JobGraph(TEST_JOB_ID, "twoVerticesJob", firstVertex, secondVertex);
	jobGraphWithTwoVertices.setAllowQueuedScheduling(true);

	CompletableFuture<Acknowledge> acknowledgeFuture = dispatcherGateway.submitJob(jobGraphWithTwoVertices, TIMEOUT);

	try {
		acknowledgeFuture.get();
		fail("job submission should have failed");
	}
	catch (ExecutionException e) {
		assertTrue(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent());
	}
}
 
Example #12
Source File: DispatcherResourceCleanupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the uploaded blobs are being cleaned up in case of a job submission failure.
 */
@Test
public void testBlobServerCleanupWhenJobSubmissionFails() throws Exception {
	startDispatcher(new FailingJobManagerRunnerFactory(new FlinkException("Test exception")));
	final CompletableFuture<Acknowledge> submissionFuture = dispatcherGateway.submitJob(jobGraph, timeout);

	try {
		submissionFuture.get();
		fail("Job submission was expected to fail.");
	} catch (ExecutionException ee) {
		assertThat(ExceptionUtils.findThrowable(ee, JobSubmissionException.class).isPresent(), is(true));
	}

	assertThatHABlobsHaveBeenRemoved();
}
 
Example #13
Source File: DispatcherTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that we can submit a job to the Dispatcher which then spawns a
 * new JobManagerRunner.
 */
@Test
public void testJobSubmissionWithPartialResourceConfigured() throws Exception {
	dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch));

	DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);

	ResourceSpec resourceSpec = ResourceSpec.newBuilder(2.0, 0).build();

	final JobVertex firstVertex = new JobVertex("firstVertex");
	firstVertex.setInvokableClass(NoOpInvokable.class);
	firstVertex.setResources(resourceSpec, resourceSpec);

	final JobVertex secondVertex = new JobVertex("secondVertex");
	secondVertex.setInvokableClass(NoOpInvokable.class);

	JobGraph jobGraphWithTwoVertices = new JobGraph(TEST_JOB_ID, "twoVerticesJob", firstVertex, secondVertex);

	CompletableFuture<Acknowledge> acknowledgeFuture = dispatcherGateway.submitJob(jobGraphWithTwoVertices, TIMEOUT);

	try {
		acknowledgeFuture.get();
		fail("job submission should have failed");
	}
	catch (ExecutionException e) {
		assertTrue(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent());
	}
}
 
Example #14
Source File: SessionDispatcherLeaderProcessTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void onAddedJobGraph_failingRecoveredJobSubmission_failsFatally() throws Exception {
	final TestingDispatcherGateway dispatcherGateway = new TestingDispatcherGateway.Builder()
		.setSubmitFunction(jobGraph -> FutureUtils.completedExceptionally(new JobSubmissionException(jobGraph.getJobID(), "test exception")))
		.build();

	runOnAddedJobGraphTest(dispatcherGateway, this::verifyOnAddedJobGraphResultFailsFatally);
}
 
Example #15
Source File: SessionDispatcherLeaderProcessTest.java    From flink with Apache License 2.0 3 votes vote down vote up
private void verifyOnAddedJobGraphResultFailsFatally(TestingFatalErrorHandler fatalErrorHandler) {
		final Throwable actualCause = fatalErrorHandler.getErrorFuture().join();

		assertTrue(ExceptionUtils.findThrowable(actualCause, JobSubmissionException.class).isPresent());

		fatalErrorHandler.clearError();
}