use of com.amazonaws.AmazonClientException in project alluxio by Alluxio.
the class S3ALowLevelOutputStream method completeMultiPartUpload.
/**
* Completes multipart upload.
*/
protected void completeMultiPartUpload(AmazonS3 s3Client, String uploadId) throws IOException {
AmazonClientException lastException;
CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest(mBucketName, mKey, uploadId, mTags);
do {
try {
s3Client.completeMultipartUpload(completeRequest);
LOG.debug("Completed multipart upload for key {} and id '{}' with {} partitions.", mKey, uploadId, mTags.size());
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// than the allowed retry count
throw new IOException("Unable to complete multipart upload with id '" + uploadId + "' to " + mKey, lastException);
}
use of com.amazonaws.AmazonClientException in project alluxio by Alluxio.
the class S3ALowLevelOutputStream method execUpload.
/**
* Executes the upload part request.
*
* @param request the upload part request
*/
protected void execUpload(AmazonS3 s3Client, UploadPartRequest request) {
File file = request.getFile();
ListenableFuture<PartETag> futureTag = mExecutor.submit((Callable) () -> {
PartETag partETag;
AmazonClientException lastException;
try {
do {
try {
partETag = s3Client.uploadPart(request).getPartETag();
return partETag;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
} finally {
// Delete the uploaded or failed to upload file
if (!file.delete()) {
LOG.error("Failed to delete temporary file @ {}", file.getPath());
}
}
throw new IOException("Fail to upload part " + request.getPartNumber() + " to " + request.getKey(), lastException);
});
mTagFutures.add(futureTag);
LOG.debug("Submit upload part request. key={}, partNum={}, file={}, fileSize={}, lastPart={}.", mKey, request.getPartNumber(), file.getPath(), file.length(), request.isLastPart());
}
use of com.amazonaws.AmazonClientException in project alluxio by Alluxio.
the class S3ALowLevelOutputStream method abortMultiPartUpload.
/**
* Aborts multipart upload.
*/
protected void abortMultiPartUpload(AmazonS3 s3Client, String uploadId) {
AmazonClientException lastException;
do {
try {
s3Client.abortMultipartUpload(new AbortMultipartUploadRequest(mBucketName, mKey, uploadId));
LOG.warn("Aborted multipart upload for key {} and id '{}' to bucket {}", mKey, uploadId, mBucketName);
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
LOG.warn("Unable to abort multipart upload for key '{}' and id '{}' to bucket {}. " + "You may need to enable the periodical cleanup by setting property {}" + "to be true.", mKey, uploadId, mBucketName, PropertyKey.UNDERFS_CLEANUP_ENABLED.getName(), lastException);
}
use of com.amazonaws.AmazonClientException in project alluxio by Alluxio.
the class S3ALowLevelOutputStream method initMultiPartUpload.
/**
* Initializes multipart upload.
*/
private void initMultiPartUpload(AmazonS3 s3Client) throws IOException {
// Generate the object metadata by setting server side encryption, md5 checksum,
// and encoding as octet stream since no assumptions are made about the file type
ObjectMetadata meta = new ObjectMetadata();
if (mSseEnabled) {
meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
}
if (mHash != null) {
meta.setContentMD5(Base64.encodeAsString(mHash.digest()));
}
meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM);
AmazonClientException lastException;
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(mBucketName, mKey).withObjectMetadata(meta);
do {
try {
mUploadId = s3Client.initiateMultipartUpload(initRequest).getUploadId();
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// than the allowed retry count
throw new IOException("Unable to init multipart upload to " + mKey, lastException);
}
use of com.amazonaws.AmazonClientException in project druid by druid-io.
the class AWSClientUtilTest method testNonRecoverableException_RuntimeException.
@Test
public void testNonRecoverableException_RuntimeException() {
AmazonClientException ex = new AmazonClientException(new RuntimeException());
Assert.assertFalse(AWSClientUtil.isClientExceptionRecoverable(ex));
}
Aggregations