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);
}
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));
}
});
}
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);
}
});
}
Aggregations