use of org.apache.flink.runtime.rest.messages.ResponseBody in project flink by apache.
the class RestClient method submitRequest.
private <P extends ResponseBody> CompletableFuture<P> submitRequest(String targetAddress, int targetPort, Request httpRequest, JavaType responseType) {
final ChannelFuture connectFuture = bootstrap.connect(targetAddress, targetPort);
final CompletableFuture<Channel> channelFuture = new CompletableFuture<>();
connectFuture.addListener((ChannelFuture future) -> {
if (future.isSuccess()) {
channelFuture.complete(future.channel());
} else {
channelFuture.completeExceptionally(future.cause());
}
});
return channelFuture.thenComposeAsync(channel -> {
ClientHandler handler = channel.pipeline().get(ClientHandler.class);
CompletableFuture<JsonResponse> future;
boolean success = false;
try {
if (handler == null) {
throw new IOException("Netty pipeline was not properly initialized.");
} else {
httpRequest.writeTo(channel);
future = handler.getJsonFuture();
success = true;
}
} catch (IOException e) {
future = FutureUtils.completedExceptionally(new ConnectionException("Could not write request.", e));
} finally {
if (!success) {
channel.close();
}
}
return future;
}, executor).thenComposeAsync((JsonResponse rawResponse) -> parseResponse(rawResponse, responseType), executor);
}
use of org.apache.flink.runtime.rest.messages.ResponseBody in project flink by apache.
the class CheckpointConfigHandler method archiveJsonWithPath.
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
ResponseBody response;
try {
response = createCheckpointConfigInfo(graph);
} catch (RestHandlerException rhe) {
response = new ErrorResponseBody(rhe.getMessage());
}
String path = CheckpointConfigHeaders.getInstance().getTargetRestEndpointURL().replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
return Collections.singletonList(new ArchivedJson(path, response));
}
use of org.apache.flink.runtime.rest.messages.ResponseBody in project flink by apache.
the class JobAccumulatorsHandler method archiveJsonWithPath.
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
ResponseBody json = createJobAccumulatorsInfo(graph, true);
String path = getMessageHeaders().getTargetRestEndpointURL().replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
return Collections.singleton(new ArchivedJson(path, json));
}
use of org.apache.flink.runtime.rest.messages.ResponseBody in project flink by apache.
the class JobConfigHandler method archiveJsonWithPath.
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
ResponseBody json = createJobConfigInfo(graph);
String path = getMessageHeaders().getTargetRestEndpointURL().replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
return Collections.singleton(new ArchivedJson(path, json));
}
use of org.apache.flink.runtime.rest.messages.ResponseBody in project flink by apache.
the class JobExceptionsHandler method archiveJsonWithPath.
@Override
public Collection<ArchivedJson> archiveJsonWithPath(ExecutionGraphInfo executionGraphInfo) throws IOException {
ResponseBody json = createJobExceptionsInfo(executionGraphInfo, MAX_NUMBER_EXCEPTION_TO_REPORT);
String path = getMessageHeaders().getTargetRestEndpointURL().replace(':' + JobIDPathParameter.KEY, executionGraphInfo.getJobId().toString());
return Collections.singletonList(new ArchivedJson(path, json));
}
Aggregations