-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Improve S3 upload speeds using aws transfer manager #17674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
77eb991
b6758ef
a103181
c881d90
284b95c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.storage.s3; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import javax.validation.constraints.Min; | ||
|
|
||
| /** | ||
| */ | ||
| public class S3TransferConfig | ||
| { | ||
| @JsonProperty | ||
| private boolean useTransferManager = true; | ||
|
|
||
| @JsonProperty | ||
| @Min(1) | ||
| private long minimumUploadPartSize = 20 * 1024 * 1024L; | ||
|
|
||
| @JsonProperty | ||
| @Min(1) | ||
| private long multipartUploadThreshold = 20 * 1024 * 1024L; | ||
|
|
||
| public void setUseTransferManager(boolean useTransferManager) | ||
| { | ||
| this.useTransferManager = useTransferManager; | ||
| } | ||
|
|
||
| public void setMinimumUploadPartSize(long minimumUploadPartSize) | ||
| { | ||
| this.minimumUploadPartSize = minimumUploadPartSize; | ||
| } | ||
|
|
||
| public void setMultipartUploadThreshold(long multipartUploadThreshold) | ||
| { | ||
| this.multipartUploadThreshold = multipartUploadThreshold; | ||
| } | ||
|
|
||
| public boolean isUseTransferManager() | ||
| { | ||
| return useTransferManager; | ||
| } | ||
|
|
||
| public long getMinimumUploadPartSize() | ||
| { | ||
| return minimumUploadPartSize; | ||
| } | ||
|
|
||
| public long getMultipartUploadThreshold() | ||
| { | ||
| return multipartUploadThreshold; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,9 @@ public boolean apply(Throwable e) | |
| // This can happen sometimes when AWS isn't able to obtain the credentials for some service: | ||
| // https://github.com/aws/aws-sdk-java/issues/2285 | ||
| return true; | ||
| } else if (e instanceof InterruptedException) { | ||
| Thread.interrupted(); // Clear interrupted state and not retry | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to clear the interrupted flag.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intention is to gracefully stop the retry operations. Let me know if your suggestion is to modify it. |
||
| return false; | ||
| } else if (e instanceof AmazonClientException) { | ||
| return AWSClientUtil.isClientExceptionRecoverable((AmazonClientException) e); | ||
| } else { | ||
|
|
@@ -348,15 +351,15 @@ static void uploadFileIfPossible( | |
| String bucket, | ||
| String key, | ||
| File file | ||
| ) | ||
| ) throws InterruptedException | ||
| { | ||
| final PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, file); | ||
|
|
||
| if (!disableAcl) { | ||
| putObjectRequest.setAccessControlList(S3Utils.grantFullControlToBucketOwner(service, bucket)); | ||
| } | ||
| log.info("Pushing [%s] to bucket[%s] and key[%s].", file, bucket, key); | ||
| service.putObject(putObjectRequest); | ||
| service.upload(putObjectRequest); | ||
| } | ||
|
|
||
| @Nullable | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.