本文整理匯總了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;
}