use of org.apache.flink.runtime.messages.FlinkJobNotFoundException in project flink by apache.
the class JobMasterQueryableStateTest method testRequestKvStateWithIrrelevantRegistration.
@Test
public void testRequestKvStateWithIrrelevantRegistration() throws Exception {
final JobMaster jobMaster = new JobMasterBuilder(JOB_GRAPH, rpcService).createJobMaster();
jobMaster.start();
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
registerSlotsRequiredForJobExecution(jobMasterGateway, JOB_GRAPH.getJobID());
try {
// register an irrelevant KvState
try {
registerKvState(jobMasterGateway, new JobID(), new JobVertexID(), "any-name");
fail("Expected to fail with FlinkJobNotFoundException.");
} catch (Exception e) {
assertThat(e, containsCause(FlinkJobNotFoundException.class));
}
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.runtime.messages.FlinkJobNotFoundException in project flink by apache.
the class ApplicationDispatcherBootstrapTest method testDuplicateJobSubmissionWithTerminatedJobIdWithUnknownResultAttached.
/**
* In this scenario, job result is no longer present in the {@link
* org.apache.flink.runtime.dispatcher.Dispatcher dispatcher} (job has terminated and job
* manager failed over), but we know that job has already terminated from {@link
* org.apache.flink.runtime.highavailability.JobResultStore}.
*/
@Test
public void testDuplicateJobSubmissionWithTerminatedJobIdWithUnknownResultAttached() 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.ofGloballyTerminated(testJobID))).setRequestJobStatusFunction(jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId))).setRequestJobResultFunction(jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)));
final CompletableFuture<Void> applicationFuture = runApplication(dispatcherBuilder, configurationUnderTest, 1);
applicationFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
use of org.apache.flink.runtime.messages.FlinkJobNotFoundException in project flink by apache.
the class JobMasterQueryableStateTest method testRequestKvStateOfWrongJob.
@Test
public void testRequestKvStateOfWrongJob() throws Exception {
final JobMaster jobMaster = new JobMasterBuilder(JOB_GRAPH, rpcService).createJobMaster();
jobMaster.start();
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
registerSlotsRequiredForJobExecution(jobMasterGateway, JOB_GRAPH.getJobID());
try {
// lookup location
try {
jobMasterGateway.requestKvStateLocation(new JobID(), "unknown").get();
fail("Expected to fail with FlinkJobNotFoundException");
} catch (Exception e) {
assertThat(e, containsCause(FlinkJobNotFoundException.class));
}
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.runtime.messages.FlinkJobNotFoundException in project flink by apache.
the class Dispatcher method cancelJob.
@Override
public CompletableFuture<Acknowledge> cancelJob(JobID jobId, Time timeout) {
Optional<JobManagerRunner> maybeJob = getJobManagerRunner(jobId);
if (maybeJob.isPresent()) {
return maybeJob.get().cancel(timeout);
}
final ExecutionGraphInfo executionGraphInfo = executionGraphInfoStore.get(jobId);
if (executionGraphInfo != null) {
final JobStatus jobStatus = executionGraphInfo.getArchivedExecutionGraph().getState();
if (jobStatus == JobStatus.CANCELED) {
return CompletableFuture.completedFuture(Acknowledge.get());
} else {
return FutureUtils.completedExceptionally(new FlinkJobTerminatedWithoutCancellationException(jobId, jobStatus));
}
}
log.debug("Dispatcher is unable to cancel job {}: not found", jobId);
return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
}
use of org.apache.flink.runtime.messages.FlinkJobNotFoundException in project flink by apache.
the class AbstractExecutionGraphHandler method handleRequest.
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
JobID jobId = request.getPathParameter(JobIDPathParameter.class);
CompletableFuture<ExecutionGraphInfo> executionGraphFuture = executionGraphCache.getExecutionGraphInfo(jobId, gateway);
return executionGraphFuture.thenApplyAsync(executionGraph -> {
try {
return handleRequest(request, executionGraph);
} catch (RestHandlerException rhe) {
throw new CompletionException(rhe);
}
}, executor).exceptionally(throwable -> {
throwable = ExceptionUtils.stripCompletionException(throwable);
if (throwable instanceof FlinkJobNotFoundException) {
throw new CompletionException(new NotFoundException(String.format("Job %s not found", jobId), throwable));
} else {
throw new CompletionException(throwable);
}
});
}
Aggregations