Search in sources :

Example 1 with ClientCoordinationResponseBody

use of org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationResponseBody in project flink by apache.

the class ClientCoordinationHandler method handleRequest.

@Override
protected CompletableFuture<ClientCoordinationResponseBody> handleRequest(@Nonnull HandlerRequest<ClientCoordinationRequestBody> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
    JobID jobId = request.getPathParameter(JobIDPathParameter.class);
    OperatorID operatorId = request.getPathParameter(OperatorIDPathParameter.class);
    SerializedValue<CoordinationRequest> serializedRequest = request.getRequestBody().getSerializedCoordinationRequest();
    CompletableFuture<CoordinationResponse> responseFuture = gateway.deliverCoordinationRequestToCoordinator(jobId, operatorId, serializedRequest, timeout);
    return responseFuture.thenApply(coordinationResponse -> {
        try {
            return new ClientCoordinationResponseBody(new SerializedValue<>(coordinationResponse));
        } catch (IOException e) {
            throw new CompletionException(new RestHandlerException("Failed to serialize coordination response", HttpResponseStatus.INTERNAL_SERVER_ERROR, e));
        }
    });
}
Also used : CoordinationResponse(org.apache.flink.runtime.operators.coordination.CoordinationResponse) CoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest) CompletionException(java.util.concurrent.CompletionException) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) IOException(java.io.IOException) ClientCoordinationResponseBody(org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationResponseBody) JobID(org.apache.flink.api.common.JobID) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException)

Aggregations

IOException (java.io.IOException)1 CompletionException (java.util.concurrent.CompletionException)1 JobID (org.apache.flink.api.common.JobID)1 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)1 CoordinationRequest (org.apache.flink.runtime.operators.coordination.CoordinationRequest)1 CoordinationResponse (org.apache.flink.runtime.operators.coordination.CoordinationResponse)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 ClientCoordinationResponseBody (org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationResponseBody)1