use of org.apache.flink.runtime.rest.messages.job.JobExecutionResultResponseBody in project flink by apache.
the class JobExecutionResultHandlerTest method testCompletedResult.
@Test
public void testCompletedResult() throws Exception {
final JobStatus jobStatus = JobStatus.FINISHED;
final ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder().setJobID(TEST_JOB_ID).setState(jobStatus).build();
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setRequestJobStatusFunction(jobId -> {
assertThat(jobId, equalTo(TEST_JOB_ID));
return CompletableFuture.completedFuture(jobStatus);
}).setRequestJobResultFunction(jobId -> {
assertThat(jobId, equalTo(TEST_JOB_ID));
return CompletableFuture.completedFuture(JobResult.createFrom(executionGraph));
}).build();
final JobExecutionResultResponseBody responseBody = jobExecutionResultHandler.handleRequest(testRequest, testingRestfulGateway).get();
assertThat(responseBody.getStatus().getId(), equalTo(QueueStatus.Id.COMPLETED));
assertThat(responseBody.getJobExecutionResult(), not(nullValue()));
}
use of org.apache.flink.runtime.rest.messages.job.JobExecutionResultResponseBody in project flink by apache.
the class JobExecutionResultHandlerTest method testResultInProgress.
@Test
public void testResultInProgress() throws Exception {
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setRequestJobStatusFunction(jobId -> CompletableFuture.completedFuture(JobStatus.RUNNING)).build();
final JobExecutionResultResponseBody responseBody = jobExecutionResultHandler.handleRequest(testRequest, testingRestfulGateway).get();
assertThat(responseBody.getStatus().getId(), equalTo(QueueStatus.Id.IN_PROGRESS));
}
use of org.apache.flink.runtime.rest.messages.job.JobExecutionResultResponseBody in project flink by apache.
the class JobExecutionResultHandler method handleRequest.
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(@Nonnull final HandlerRequest<EmptyRequestBody> request, @Nonnull final RestfulGateway gateway) throws RestHandlerException {
final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
final CompletableFuture<JobStatus> jobStatusFuture = gateway.requestJobStatus(jobId, timeout);
return jobStatusFuture.thenCompose(jobStatus -> {
if (jobStatus.isGloballyTerminalState()) {
return gateway.requestJobResult(jobId, timeout).thenApply(JobExecutionResultResponseBody::created);
} else {
return CompletableFuture.completedFuture(JobExecutionResultResponseBody.inProgress());
}
}).exceptionally(throwable -> {
throw propagateException(throwable);
});
}
Aggregations