本文整理汇总了Java中org.eclipse.jetty.http.HttpStatus.TOO_MANY_REQUESTS_429属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.TOO_MANY_REQUESTS_429属性的具体用法?Java HttpStatus.TOO_MANY_REQUESTS_429怎么用?Java HttpStatus.TOO_MANY_REQUESTS_429使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jetty.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.TOO_MANY_REQUESTS_429属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
private RuntimeException error(Request req, boolean uriIsSecret, Response res)
{
if (HttpStatus.isClientError(res.getStatus())) {
switch (res.getStatus()) {
case HttpStatus.REQUEST_TIMEOUT_408:
case HttpStatus.TOO_MANY_REQUESTS_429:
// Retry these.
return new RuntimeException("Failed HTTP request: " + requestStatus(req, res, uriIsSecret));
default:
// 4xx: The request is invalid for this resource. Fail hard without retrying.
return new TaskExecutionException("HTTP 4XX Client Error: " + requestStatus(req, res, uriIsSecret));
}
}
else if (res.getStatus() >= 500 && res.getStatus() < 600) {
// 5xx: Server Error. This is hopefully ephemeral.
return ephemeralError("HTTP 5XX Server Error: " + requestStatus(req, res, uriIsSecret));
}
else {
// Unknown status code. Treat as an ephemeral error.
return ephemeralError("Unexpected HTTP status: " + requestStatus(req, res, uriIsSecret));
}
}
示例2: isDeterministicException
static boolean isDeterministicException(GoogleJsonResponseException e)
{
int statusCode = e.getStatusCode();
switch (statusCode) {
case HttpStatus.TOO_MANY_REQUESTS_429:
case HttpStatus.REQUEST_TIMEOUT_408:
return false;
default:
return statusCode >= 400 && statusCode < 500;
}
}
示例3: isDeterministicException
static boolean isDeterministicException(AmazonServiceException ex)
{
int statusCode = ex.getStatusCode();
switch (statusCode) {
case HttpStatus.TOO_MANY_REQUESTS_429:
case HttpStatus.REQUEST_TIMEOUT_408:
return false;
default:
return statusCode >= 400 && statusCode < 500;
}
}
示例4: isDeterministicClientException
static boolean isDeterministicClientException(Exception ex)
{
if (ex instanceof TDClientHttpException) {
int statusCode = ((TDClientHttpException) ex).getStatusCode();
switch (statusCode) {
case HttpStatus.TOO_MANY_REQUESTS_429:
case HttpStatus.REQUEST_TIMEOUT_408:
return false;
default:
// return true if 4xx
return statusCode >= 400 && statusCode < 500;
}
}
else if (ex instanceof TDClientException) {
// failed before sending HTTP request or receiving HTTP response
TDClientException.ErrorType errorType = ((TDClientException) ex).getErrorType();
switch (errorType) {
case INVALID_CONFIGURATION: // failed to read td.conf, failed to pares integer in properties set to TDClientBuilder, etc.
case INVALID_INPUT: // early table name validation fails, failed to format request body in json, etc.
return true;
default:
// other cases such as PROXY_AUTHENTICATION_FAILURE, SSL_ERROR, REQUEST_TIMEOUT, INTERRUPTED, etc.
break; // pass-through
}
}
return false;
}