Search in sources :

Example 11 with ErrorResponseBody

use of org.apache.flink.runtime.rest.messages.ErrorResponseBody 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));
}
Also used : ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) ErrorResponseBody(org.apache.flink.runtime.rest.messages.ErrorResponseBody) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) ErrorResponseBody(org.apache.flink.runtime.rest.messages.ErrorResponseBody) ResponseBody(org.apache.flink.runtime.rest.messages.ResponseBody)

Example 12 with ErrorResponseBody

use of org.apache.flink.runtime.rest.messages.ErrorResponseBody in project flink by apache.

the class StaticFileServerHandler method respondAsLeader.

// ------------------------------------------------------------------------
// Responses to requests
// ------------------------------------------------------------------------
@Override
protected void respondAsLeader(ChannelHandlerContext channelHandlerContext, RoutedRequest routedRequest, T gateway) throws Exception {
    final HttpRequest request = routedRequest.getRequest();
    final String requestPath;
    // make sure we request the "index.html" in case there is a directory request
    if (routedRequest.getPath().endsWith("/")) {
        requestPath = routedRequest.getPath() + "index.html";
    } else {
        requestPath = routedRequest.getPath();
    }
    try {
        respondToRequest(channelHandlerContext, request, requestPath);
    } catch (RestHandlerException rhe) {
        HandlerUtils.sendErrorResponse(channelHandlerContext, routedRequest.getRequest(), new ErrorResponseBody(rhe.getMessage()), rhe.getHttpResponseStatus(), responseHeaders);
    }
}
Also used : HttpRequest(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest) ErrorResponseBody(org.apache.flink.runtime.rest.messages.ErrorResponseBody) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException)

Example 13 with ErrorResponseBody

use of org.apache.flink.runtime.rest.messages.ErrorResponseBody in project flink by apache.

the class StaticFileServerHandler method exceptionCaught.

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    if (ctx.channel().isActive()) {
        logger.error("Caught exception", cause);
        HandlerUtils.sendErrorResponse(ctx, false, new ErrorResponseBody("Internal server error."), INTERNAL_SERVER_ERROR, Collections.emptyMap());
    }
}
Also used : ErrorResponseBody(org.apache.flink.runtime.rest.messages.ErrorResponseBody)

Aggregations

ErrorResponseBody (org.apache.flink.runtime.rest.messages.ErrorResponseBody)13 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)4 HttpRequest (org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest)3 IOException (java.io.IOException)2 ResponseBody (org.apache.flink.runtime.rest.messages.ResponseBody)2 ArchivedJson (org.apache.flink.runtime.webmonitor.history.ArchivedJson)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 URI (java.net.URI)1 URL (java.net.URL)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Nonnull (javax.annotation.Nonnull)1 Time (org.apache.flink.api.common.time.Time)1 FlinkHttpObjectAggregator (org.apache.flink.runtime.rest.FlinkHttpObjectAggregator)1