當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpStatus.TOO_MANY_REQUESTS_429屬性代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:treasure-data,項目名稱:digdag,代碼行數:22,代碼來源:HttpOperatorFactory.java

示例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;
    }
}
 
開發者ID:gymxxx,項目名稱:digdag-bq-wait,代碼行數:11,代碼來源:Gcp.java

示例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;
    }
}
 
開發者ID:treasure-data,項目名稱:digdag,代碼行數:11,代碼來源:Aws.java

示例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;
}
 
開發者ID:treasure-data,項目名稱:digdag,代碼行數:27,代碼來源:TDOperator.java


注:本文中的org.eclipse.jetty.http.HttpStatus.TOO_MANY_REQUESTS_429屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。