|
83 | 83 | import software.amazon.awssdk.services.s3.model.PutObjectRequest;
|
84 | 84 | import software.amazon.awssdk.services.s3.model.PutObjectResponse;
|
85 | 85 | import software.amazon.awssdk.services.s3.model.S3Error;
|
86 |
| -import software.amazon.awssdk.services.s3.model.S3Exception; |
87 | 86 | import software.amazon.awssdk.services.s3.model.S3Object;
|
88 | 87 | import software.amazon.awssdk.services.s3.model.SelectObjectContentRequest;
|
89 | 88 | import software.amazon.awssdk.services.s3.model.SelectObjectContentResponseHandler;
|
|
98 | 97 | import software.amazon.awssdk.transfer.s3.model.FileUpload;
|
99 | 98 | import software.amazon.awssdk.transfer.s3.model.UploadFileRequest;
|
100 | 99 |
|
101 |
| -import org.apache.commons.lang3.StringUtils; |
102 | 100 | import org.apache.hadoop.fs.impl.prefetch.ExecutorServiceFuturePool;
|
103 | 101 | import org.slf4j.Logger;
|
104 | 102 | import org.slf4j.LoggerFactory;
|
|
249 | 247 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.CSE_PADDING_LENGTH;
|
250 | 248 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.DEFAULT_UPLOAD_PART_COUNT_LIMIT;
|
251 | 249 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.DELETE_CONSIDERED_IDEMPOTENT;
|
252 |
| -import static org.apache.hadoop.fs.s3a.impl.InternalConstants.SC_301_MOVED_PERMANENTLY; |
253 | 250 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.SC_403_FORBIDDEN;
|
254 | 251 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.SC_404_NOT_FOUND;
|
255 | 252 | import static org.apache.hadoop.fs.s3a.impl.InternalConstants.UPLOAD_PART_COUNT_LIMIT;
|
@@ -334,8 +331,7 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities,
|
334 | 331 | private int executorCapacity;
|
335 | 332 | private long multiPartThreshold;
|
336 | 333 | public static final Logger LOG = LoggerFactory.getLogger(S3AFileSystem.class);
|
337 |
| - /** Exactly once log to warn about setting the region in config to avoid probe. */ |
338 |
| - private static final LogExactlyOnce SET_REGION_WARNING = new LogExactlyOnce(LOG); |
| 334 | + |
339 | 335 | private static final Logger PROGRESS =
|
340 | 336 | LoggerFactory.getLogger("org.apache.hadoop.fs.s3a.S3AFileSystem.Progress");
|
341 | 337 | private LocalDirAllocator directoryAllocator;
|
@@ -1016,74 +1012,6 @@ private synchronized void createS3AsyncClient(S3ClientFactory clientFactory,
|
1016 | 1012 | s3AsyncClient = clientFactory.createS3AsyncClient(getUri(), parameters);
|
1017 | 1013 | }
|
1018 | 1014 |
|
1019 |
| - /** |
1020 |
| - * Get the bucket region. |
1021 |
| - * |
1022 |
| - * @param region AWS S3 Region set in the config. This property may not be set, in which case |
1023 |
| - * ask S3 for the region. |
1024 |
| - * @return region of the bucket. |
1025 |
| - */ |
1026 |
| - private Region getS3Region(String region) throws IOException { |
1027 |
| - |
1028 |
| - if (!StringUtils.isBlank(region)) { |
1029 |
| - return Region.of(region); |
1030 |
| - } |
1031 |
| - |
1032 |
| - Region cachedRegion = BUCKET_REGIONS.get(bucket); |
1033 |
| - |
1034 |
| - if (cachedRegion != null) { |
1035 |
| - LOG.debug("Got region {} for bucket {} from cache", cachedRegion, bucket); |
1036 |
| - return cachedRegion; |
1037 |
| - } |
1038 |
| - |
1039 |
| - Region s3Region = trackDurationAndSpan(STORE_REGION_PROBE, bucket, null, |
1040 |
| - () -> invoker.retry("getS3Region", bucket, true, () -> { |
1041 |
| - try { |
1042 |
| - |
1043 |
| - SET_REGION_WARNING.warn( |
1044 |
| - "Getting region for bucket {} from S3, this will slow down FS initialisation. " |
1045 |
| - + "To avoid this, set the region using property {}", bucket, |
1046 |
| - FS_S3A_BUCKET_PREFIX + bucket + ".endpoint.region"); |
1047 |
| - |
1048 |
| - // build a s3 client with region eu-west-1 that can be used to get the region of the |
1049 |
| - // bucket. Using eu-west-1, as headBucket() doesn't work with us-east-1. This is because |
1050 |
| - // us-east-1 uses the endpoint s3.amazonaws.com, which resolves bucket.s3.amazonaws.com |
1051 |
| - // to the actual region the bucket is in. As the request is signed with us-east-1 and |
1052 |
| - // not the bucket's region, it fails. |
1053 |
| - S3Client getRegionS3Client = |
1054 |
| - S3Client.builder().region(Region.EU_WEST_1).credentialsProvider(credentials) |
1055 |
| - .build(); |
1056 |
| - |
1057 |
| - HeadBucketResponse headBucketResponse = |
1058 |
| - getRegionS3Client.headBucket(HeadBucketRequest.builder().bucket(bucket).build()); |
1059 |
| - |
1060 |
| - Region bucketRegion = Region.of( |
1061 |
| - headBucketResponse.sdkHttpResponse().headers().get(BUCKET_REGION_HEADER).get(0)); |
1062 |
| - BUCKET_REGIONS.put(bucket, bucketRegion); |
1063 |
| - |
1064 |
| - return bucketRegion; |
1065 |
| - } catch (S3Exception exception) { |
1066 |
| - if (exception.statusCode() == SC_301_MOVED_PERMANENTLY) { |
1067 |
| - Region bucketRegion = Region.of( |
1068 |
| - exception.awsErrorDetails().sdkHttpResponse().headers().get(BUCKET_REGION_HEADER) |
1069 |
| - .get(0)); |
1070 |
| - BUCKET_REGIONS.put(bucket, bucketRegion); |
1071 |
| - |
1072 |
| - return bucketRegion; |
1073 |
| - } |
1074 |
| - |
1075 |
| - if (exception.statusCode() == SC_404_NOT_FOUND) { |
1076 |
| - throw new UnknownStoreException("s3a://" + bucket + "/", |
1077 |
| - " Bucket does " + "not exist"); |
1078 |
| - } |
1079 |
| - |
1080 |
| - throw exception; |
1081 |
| - } |
1082 |
| - })); |
1083 |
| - |
1084 |
| - return s3Region; |
1085 |
| - } |
1086 |
| - |
1087 | 1015 | /**
|
1088 | 1016 | * Initialize and launch the audit manager and service.
|
1089 | 1017 | * As this takes the FS IOStatistics store, it must be invoked
|
|
0 commit comments