Thread pool rejection status code should be 429

Thread rejection should return too many requests status code, and not 503, which is used to also show that the cluster is not available
 relates to #6627, but only for rejections for now
closes #6629
This commit is contained in:
Shay Banon 2014-06-26 14:16:24 +02:00
parent 4129bb6a4f
commit 79af3228ad
3 changed files with 10 additions and 2 deletions

View File

@ -40,6 +40,6 @@ public class EsRejectedExecutionException extends ElasticsearchException {
@Override
public RestStatus status() {
return RestStatus.SERVICE_UNAVAILABLE;
return RestStatus.TOO_MANY_REQUESTS;
}
}

View File

@ -185,6 +185,8 @@ public class NettyHttpChannel extends HttpChannel {
}
}
private static final HttpResponseStatus TOO_MANY_REQUESTS = new HttpResponseStatus(429, "Too Many Requests");
private HttpResponseStatus getStatus(RestStatus status) {
switch (status) {
case CONTINUE:
@ -264,6 +266,8 @@ public class NettyHttpChannel extends HttpChannel {
return HttpResponseStatus.BAD_REQUEST;
case FAILED_DEPENDENCY:
return HttpResponseStatus.BAD_REQUEST;
case TOO_MANY_REQUESTS:
return TOO_MANY_REQUESTS;
case INTERNAL_SERVER_ERROR:
return HttpResponseStatus.INTERNAL_SERVER_ERROR;
case NOT_IMPLEMENTED:

View File

@ -428,6 +428,10 @@ public enum RestStatus {
* PROPPATCH method fails, then, at minimum, the rest of the commands will also fail with 424 (Failed Dependency).
*/
FAILED_DEPENDENCY(424),
/**
* 429 Too Many Requests (RFC6585)
*/
TOO_MANY_REQUESTS(429),
/**
* The server encountered an unexpected condition which prevented it from fulfilling the request.
*/
@ -490,4 +494,4 @@ public enum RestStatus {
public static void writeTo(StreamOutput out, RestStatus status) throws IOException {
out.writeString(status.name());
}
}
}