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


Java AmazonClientException.isRetryable方法代碼示例

本文整理匯總了Java中com.amazonaws.AmazonClientException.isRetryable方法的典型用法代碼示例。如果您正苦於以下問題:Java AmazonClientException.isRetryable方法的具體用法?Java AmazonClientException.isRetryable怎麽用?Java AmazonClientException.isRetryable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.AmazonClientException的用法示例。


在下文中一共展示了AmazonClientException.isRetryable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldRetry

import com.amazonaws.AmazonClientException; //導入方法依賴的package包/類
protected boolean shouldRetry(AmazonClientException e) {
    if (e instanceof AmazonS3Exception) {
        AmazonS3Exception s3e = (AmazonS3Exception) e;
        if (s3e.getStatusCode() == 400 && "RequestTimeout".equals(s3e.getErrorCode())) {
            return true;
        }
    }
    return e.isRetryable();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:S3BlobStore.java

示例2: retryableDownloadS3ObjectToFile

import com.amazonaws.AmazonClientException; //導入方法依賴的package包/類
private S3Object retryableDownloadS3ObjectToFile(File file,
        RetryableS3DownloadTask retryableS3DownloadTask) {
    boolean hasRetried = false;
    S3Object s3Object;
    for (;;) {
        final boolean appendData = resumeExistingDownload || (resumeOnRetry && hasRetried);
        if (appendData && hasRetried) {
            // Need to adjust the get range or else we risk corrupting the downloaded file
            adjustRequest(req);
        }
        s3Object = retryableS3DownloadTask.getS3ObjectStream();
        if (s3Object == null)
            return null;
        try {
            if (testing && resumeExistingDownload && !hasRetried) {
                throw new SdkClientException("testing");
            }
            ServiceUtils.downloadToFile(s3Object, file,
                    retryableS3DownloadTask.needIntegrityCheck(),
                    appendData, expectedFileLength);
            return s3Object;
        } catch (AmazonClientException ace) {
            if (!ace.isRetryable())
                throw ace;
            // Determine whether an immediate retry is needed according to the captured SdkClientException.
            // (There are three cases when downloadObjectToFile() throws SdkClientException:
            //      1) SocketException or SSLProtocolException when writing to disk (e.g. when user aborts the download)
            //      2) Other IOException when writing to disk
            //      3) MD5 hashes don't match
            // For 1) If SocketException is the result of the client side resetting the connection, this is retried
            // Cases 2) and 3) will always be retried
            final Throwable cause = ace.getCause();
            if ((cause instanceof SocketException && !cause.getMessage().equals("Connection reset"))
                || (cause instanceof SSLProtocolException)) {
                throw ace;
            } else {
                if (hasRetried)
                    throw ace;
                else {
                    LOG.info("Retry the download of object " + s3Object.getKey() + " (bucket " + s3Object.getBucketName() + ")", ace);
                    hasRetried = true;
                }
            }
        } finally {
            s3Object.getObjectContent().abort();
        }
    }
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:49,代碼來源:DownloadCallable.java


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