Skip to content
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

HADOOP-18073. Adds in s3 client config and updates list. #4706

Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds some constants
ahmarsuhail committed Aug 25, 2022
commit 4dd228d40d0b7c28ccf2e52212dd20fa2dd8238e
Original file line number Diff line number Diff line change
@@ -1204,4 +1204,13 @@ private Constants() {
*/
public static final int DEFAULT_AWS_S3_VECTOR_READS_MAX_MERGED_READ_SIZE = 1253376; //1M

ahmarsuhail marked this conversation as resolved.
Show resolved Hide resolved
/**
* The bucket region header.
*/
public static final String BUCKET_REGION_HEADER = "x-amz-bucket-region";

/**
* Status code for moved permanently.
*/
public static final int HTTP_STATUS_CODE_MOVED_PERMANENTLY = 301;
}
Original file line number Diff line number Diff line change
@@ -75,10 +75,12 @@
import static com.amazonaws.services.s3.Headers.REQUESTER_PAYS_HEADER;
import static org.apache.hadoop.fs.s3a.Constants.AWS_REGION;
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_CENTRAL_REGION;
import static org.apache.hadoop.fs.s3a.Constants.BUCKET_REGION_HEADER;
import static org.apache.hadoop.fs.s3a.Constants.CENTRAL_ENDPOINT;
import static org.apache.hadoop.fs.s3a.Constants.DEFAULT_SECURE_CONNECTIONS;
import static org.apache.hadoop.fs.s3a.Constants.EXPERIMENTAL_AWS_INTERNAL_THROTTLING;
import static org.apache.hadoop.fs.s3a.Constants.EXPERIMENTAL_AWS_INTERNAL_THROTTLING_DEFAULT;
import static org.apache.hadoop.fs.s3a.Constants.HTTP_STATUS_CODE_MOVED_PERMANENTLY;
import static org.apache.hadoop.fs.s3a.Constants.S3_ENCRYPTION_KEY;
import static org.apache.hadoop.fs.s3a.Constants.SECURE_CONNECTIONS;
import static org.apache.hadoop.fs.s3a.S3AUtils.getEncryptionAlgorithm;
@@ -540,9 +542,9 @@ private Region getS3Region(String region, AWSCredentialsProvider credentialsProv
HeadBucketResponse headBucketResponse =
s3Client.headBucket(HeadBucketRequest.builder().bucket(bucket).build());
return Region.of(
headBucketResponse.sdkHttpResponse().headers().get("x-amz-bucket-region").get(0));
headBucketResponse.sdkHttpResponse().headers().get(BUCKET_REGION_HEADER).get(0));
} catch (S3Exception exception) {
if (exception.statusCode() == 301) {
if (exception.statusCode() == HTTP_STATUS_CODE_MOVED_PERMANENTLY) {
List<String> bucketRegion =
exception.awsErrorDetails().sdkHttpResponse().headers().get("x-amz-bucket-region");
ahmarsuhail marked this conversation as resolved.
Show resolved Hide resolved
return Region.of(bucketRegion.get(0));