Skip to content

Commit fffb0bd

Browse files
ashutoshpantsteveloughran
authored andcommitted
HADOOP-18330. S3AFileSystem removes Path when calling createS3Client (#4572)
Adds a new parameter object in s3ClientCreationParameters that holds the full s3a path URI Contributed by Ashutosh Pant
1 parent 36cb8a6 commit fffb0bd

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ private void bindAWSClient(URI name, boolean dtEnabled) throws IOException {
888888
S3ClientFactory.S3ClientCreationParameters parameters = null;
889889
parameters = new S3ClientFactory.S3ClientCreationParameters()
890890
.withCredentialSet(credentials)
891+
.withPathUri(name)
891892
.withEndpoint(endpoint)
892893
.withMetrics(statisticsContext.newStatisticsFromAwsSdk())
893894
.withPathStyleAccess(conf.getBoolean(PATH_STYLE_ACCESS, false))

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ClientFactory.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ final class S3ClientCreationParameters {
115115
*/
116116
private String userAgentSuffix = "";
117117

118+
/**
119+
* S3A path.
120+
* added in HADOOP-18330
121+
*/
122+
private URI pathUri;
123+
118124
/**
119125
* List of request handlers to include in the chain
120126
* of request execution in the SDK.
@@ -264,5 +270,26 @@ public S3ClientCreationParameters withHeader(
264270
public Map<String, String> getHeaders() {
265271
return headers;
266272
}
273+
274+
/**
275+
* Get the full s3 path.
276+
* added in HADOOP-18330
277+
* @return path URI
278+
*/
279+
public URI getPathUri() {
280+
return pathUri;
281+
}
282+
283+
/**
284+
* Set full s3a path.
285+
* added in HADOOP-18330
286+
* @param value new value
287+
* @return the builder
288+
*/
289+
public S3ClientCreationParameters withPathUri(
290+
final URI value) {
291+
pathUri = value;
292+
return this;
293+
}
267294
}
268295
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private AmazonS3 createS3Client(Configuration conf,
176176
S3ClientFactory.S3ClientCreationParameters parameters
177177
= new S3ClientFactory.S3ClientCreationParameters()
178178
.withCredentialSet(new AnonymousAWSCredentialsProvider())
179+
.withPathUri(new URI("s3a://localhost/"))
179180
.withEndpoint(endpoint)
180181
.withMetrics(new EmptyS3AStatisticsContext()
181182
.newStatisticsFromAwsSdk());

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/delegation/ITestSessionDelegationInFileystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ protected ObjectMetadata readLandsatMetadata(final S3AFileSystem delegatedFS)
589589
S3ClientFactory.S3ClientCreationParameters parameters = null;
590590
parameters = new S3ClientFactory.S3ClientCreationParameters()
591591
.withCredentialSet(testingCreds)
592+
.withPathUri(new URI("s3a://localhost/"))
592593
.withEndpoint(DEFAULT_ENDPOINT)
593594
.withMetrics(new EmptyS3AStatisticsContext()
594595
.newStatisticsFromAwsSdk())

0 commit comments

Comments
 (0)