Search in sources :

Example 1 with CoordinationRequest

use of org.apache.flink.runtime.operators.coordination.CoordinationRequest in project flink by apache.

the class AdaptiveSchedulerTest method testDeliverCoordinationRequestToCoordinatorFailsInIllegalState.

@Test
public void testDeliverCoordinationRequestToCoordinatorFailsInIllegalState() throws Exception {
    final AdaptiveScheduler scheduler = new AdaptiveSchedulerBuilder(createJobGraph(), mainThreadExecutor).build();
    assertThat(scheduler.deliverCoordinationRequestToCoordinator(new OperatorID(), new CoordinationRequest() {
    })).failsWithin(1, TimeUnit.MILLISECONDS).withThrowableOfType(ExecutionException.class).withCauseInstanceOf(FlinkException.class);
}
Also used : CoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Example 2 with CoordinationRequest

use of org.apache.flink.runtime.operators.coordination.CoordinationRequest 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)

Example 3 with CoordinationRequest

use of org.apache.flink.runtime.operators.coordination.CoordinationRequest 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

CoordinationRequest (org.apache.flink.runtime.operators.coordination.CoordinationRequest)3 IOException (java.io.IOException)2 CompletionException (java.util.concurrent.CompletionException)2 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)2 ExecutionException (java.util.concurrent.ExecutionException)1 JobID (org.apache.flink.api.common.JobID)1 ArchivedExecutionGraphTest (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest)1 CoordinationResponse (org.apache.flink.runtime.operators.coordination.CoordinationResponse)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)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 ClientCoordinationResponseBody (org.apache.flink.runtime.rest.messages.job.coordination.ClientCoordinationResponseBody)1 DefaultSchedulerTest (org.apache.flink.runtime.scheduler.DefaultSchedulerTest)1 Test (org.junit.Test)1