Java Code Examples for io.netty.handler.codec.http.HttpResponseStatus#REQUEST_TIMEOUT

The following examples show how to use io.netty.handler.codec.http.HttpResponseStatus#REQUEST_TIMEOUT . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: serve   File: ManagementRequestHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void handleUnregisterModel(
        ChannelHandlerContext ctx, String modelName, String modelVersion)
        throws ModelNotFoundException, InternalServerException, RequestTimeoutException,
                ModelVersionNotFoundException {
    ModelManager modelManager = ModelManager.getInstance();
    HttpResponseStatus httpResponseStatus =
            modelManager.unregisterModel(modelName, modelVersion);
    if (httpResponseStatus == HttpResponseStatus.NOT_FOUND) {
        throw new ModelNotFoundException("Model not found: " + modelName);
    } else if (httpResponseStatus == HttpResponseStatus.BAD_REQUEST) {
        throw new ModelVersionNotFoundException(
                String.format(
                        "Model version: %s does not exist for model: %s",
                        modelVersion, modelName));
    } else if (httpResponseStatus == HttpResponseStatus.INTERNAL_SERVER_ERROR) {
        throw new InternalServerException("Interrupted while cleaning resources: " + modelName);
    } else if (httpResponseStatus == HttpResponseStatus.REQUEST_TIMEOUT) {
        throw new RequestTimeoutException("Timed out while cleaning resources: " + modelName);
    } else if (httpResponseStatus == HttpResponseStatus.FORBIDDEN) {
        throw new InvalidModelVersionException(
                "Cannot remove default version for model " + modelName);
    }
    String msg = "Model \"" + modelName + "\" unregistered";
    NettyUtils.sendJsonResponse(ctx, new StatusResponse(msg));
}
 
Example 2
private void handleUnregisterModel(ChannelHandlerContext ctx, String modelName)
        throws ModelNotFoundException, InternalServerException, RequestTimeoutException {
    ModelManager modelManager = ModelManager.getInstance();
    HttpResponseStatus httpResponseStatus = modelManager.unregisterModel(modelName);
    if (httpResponseStatus == HttpResponseStatus.NOT_FOUND) {
        throw new ModelNotFoundException("Model not found: " + modelName);
    } else if (httpResponseStatus == HttpResponseStatus.INTERNAL_SERVER_ERROR) {
        throw new InternalServerException("Interrupted while cleaning resources: " + modelName);
    } else if (httpResponseStatus == HttpResponseStatus.REQUEST_TIMEOUT) {
        throw new RequestTimeoutException("Timed out while cleaning resources: " + modelName);
    }
    String msg = "Model \"" + modelName + "\" unregistered";
    NettyUtils.sendJsonResponse(ctx, new StatusResponse(msg));
}
 
Example 3
public GatewayTimeoutException() {
    super(HttpResponseStatus.REQUEST_TIMEOUT, "request timeout");
}