Search in sources :

Example 1 with JobCancellationMessageParameters

use of org.apache.flink.runtime.rest.messages.JobCancellationMessageParameters in project flink by apache.

the class JobCancellationHandlerTest method testResponse.

private static void testResponse(Function<JobID, CompletableFuture<Acknowledge>> cancelJobFunction, ThrowingConsumer<CompletableFuture<EmptyResponseBody>, Exception> assertion) throws Exception {
    final RestfulGateway gateway = createGateway(cancelJobFunction);
    final JobCancellationHandler jobCancellationHandler = createHandler(gateway);
    final JobCancellationMessageParameters messageParameters = jobCancellationHandler.getMessageHeaders().getUnresolvedMessageParameters().resolveJobId(new JobID());
    final CompletableFuture<EmptyResponseBody> cancellationFuture = jobCancellationHandler.handleRequest(HandlerRequest.create(EmptyRequestBody.getInstance(), messageParameters), gateway);
    assertion.accept(cancellationFuture);
}
Also used : JobCancellationMessageParameters(org.apache.flink.runtime.rest.messages.JobCancellationMessageParameters) EmptyResponseBody(org.apache.flink.runtime.rest.messages.EmptyResponseBody) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) RestfulGateway(org.apache.flink.runtime.webmonitor.RestfulGateway) JobID(org.apache.flink.api.common.JobID)

Example 2 with JobCancellationMessageParameters

use of org.apache.flink.runtime.rest.messages.JobCancellationMessageParameters in project flink by apache.

the class RestClusterClient method cancel.

@Override
public CompletableFuture<Acknowledge> cancel(JobID jobID) {
    JobCancellationMessageParameters params = new JobCancellationMessageParameters().resolveJobId(jobID).resolveTerminationMode(TerminationModeQueryParameter.TerminationMode.CANCEL);
    CompletableFuture<EmptyResponseBody> responseFuture = sendRequest(JobCancellationHeaders.getInstance(), params);
    return responseFuture.thenApply(ignore -> Acknowledge.get());
}
Also used : JobCancellationMessageParameters(org.apache.flink.runtime.rest.messages.JobCancellationMessageParameters) EmptyResponseBody(org.apache.flink.runtime.rest.messages.EmptyResponseBody)

Aggregations

EmptyResponseBody (org.apache.flink.runtime.rest.messages.EmptyResponseBody)2 JobCancellationMessageParameters (org.apache.flink.runtime.rest.messages.JobCancellationMessageParameters)2 JobID (org.apache.flink.api.common.JobID)1 RestfulGateway (org.apache.flink.runtime.webmonitor.RestfulGateway)1 TestingRestfulGateway (org.apache.flink.runtime.webmonitor.TestingRestfulGateway)1