S3Utils: Fix retry predicate

This commit is contained in:
Gian Merlino 2013-12-16 08:27:00 -08:00
parent 2dd4860106
commit 36756e611b
1 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,7 @@ package io.druid.storage.s3;
import com.google.common.base.Predicate;
import com.metamx.common.RetryUtils;
import org.jets3t.service.S3ServiceException;
import org.jets3t.service.ServiceException;
import org.jets3t.service.impl.rest.httpclient.RestS3Service;
import org.jets3t.service.model.S3Bucket;
import org.jets3t.service.model.S3Object;
@ -61,9 +61,9 @@ public class S3Utils
{
if (e instanceof IOException) {
return true;
} else if (e instanceof S3ServiceException) {
} else if (e instanceof ServiceException) {
final boolean isIOException = e.getCause() instanceof IOException;
final boolean isTimeout = "RequestTimeout".equals(((S3ServiceException) e).getS3ErrorCode());
final boolean isTimeout = "RequestTimeout".equals(((ServiceException) e).getErrorCode());
return isIOException || isTimeout;
} else {
return false;
@ -75,18 +75,18 @@ public class S3Utils
}
public static boolean isObjectInBucket(RestS3Service s3Client, String bucketName, String objectKey)
throws S3ServiceException
throws ServiceException
{
try {
s3Client.getObjectDetails(new S3Bucket(bucketName), objectKey);
}
catch (S3ServiceException e) {
catch (ServiceException e) {
if (404 == e.getResponseCode()
|| "NoSuchKey".equals(e.getS3ErrorCode())
|| "NoSuchBucket".equals(e.getS3ErrorCode())) {
|| "NoSuchKey".equals(e.getErrorCode())
|| "NoSuchBucket".equals(e.getErrorCode())) {
return false;
}
if ("AccessDenied".equals(e.getS3ErrorCode())) {
if ("AccessDenied".equals(e.getErrorCode())) {
// Object is inaccessible to current user, but does exist.
return true;
}