下面列出了 io.netty.handler.codec.http.HttpResponseStatus # REQUEST_TIMEOUT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
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));
}
public GatewayTimeoutException() {
super(HttpResponseStatus.REQUEST_TIMEOUT, "request timeout");
}