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 . 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 File: ManagementRequestHandler.java    From serve with 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
Source File: ManagementRequestHandler.java    From multi-model-server with Apache License 2.0 5 votes vote down vote up
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
Source File: GatewayTimeoutException.java    From api-gateway-core with Apache License 2.0 4 votes vote down vote up
public GatewayTimeoutException() {
    super(HttpResponseStatus.REQUEST_TIMEOUT, "request timeout");
}