Search in sources :

Example 1 with ClientCoordinationMessageParameters

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

the class RestClusterClient method sendCoordinationRequest.

@Override
public CompletableFuture<CoordinationResponse> sendCoordinationRequest(JobID jobId, OperatorID operatorId, CoordinationRequest request) {
    ClientCoordinationHeaders headers = ClientCoordinationHeaders.getInstance();
    ClientCoordinationMessageParameters params = new ClientCoordinationMessageParameters();
    params.jobPathParameter.resolve(jobId);
    params.operatorPathParameter.resolve(operatorId);
    SerializedValue<CoordinationRequest> serializedRequest;
    try {
        serializedRequest = new SerializedValue<>(request);
    } catch (IOException e) {
        return FutureUtils.completedExceptionally(e);
    }
    ClientCoordinationRequestBody requestBody = new ClientCoordinationRequestBody(serializedRequest);
    return sendRequest(headers, params, requestBody).thenApply(responseBody -> {
        try {
            return responseBody.getSerializedCoordinationResponse().deserializeValue(getClass().getClassLoader());
        } catch (IOException | ClassNotFoundException e) {
            throw new CompletionException("Failed to deserialize coordination response", e);
        }
    });
}
Also used : ClientCoordinationHeaders(org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationHeaders) ClientCoordinationMessageParameters(org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationMessageParameters) CoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest) CompletionException(java.util.concurrent.CompletionException) ClientCoordinationRequestBody(org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationRequestBody) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 CompletionException (java.util.concurrent.CompletionException)1 CoordinationRequest (org.apache.flink.runtime.operators.coordination.CoordinationRequest)1 ClientCoordinationHeaders (org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationHeaders)1 ClientCoordinationMessageParameters (org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationMessageParameters)1 ClientCoordinationRequestBody (org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationRequestBody)1