Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions hadoop-ozone/integration-test-s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@
<artifactId>hadoop-common</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-minikdc</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_HTTP_ADDRESS_KEY;

import java.net.URI;
import java.util.function.Consumer;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.server.http.HttpConfig;
import org.slf4j.Logger;
Expand All @@ -41,6 +42,8 @@
* Factory class for creating S3 clients.
*/
public class S3ClientFactory {
public static final String ACCESS_KEY = "user";
public static final String SECRET_KEY = "password";
private static final Logger LOG = LoggerFactory.getLogger(S3ClientFactory.class);
private final OzoneConfiguration conf;

Expand Down Expand Up @@ -71,8 +74,14 @@ public S3Client createS3ClientV2() throws Exception {
* @throws Exception if there is an error creating the client
*/
public S3Client createS3ClientV2(boolean enablePathStyle) throws Exception {
return createS3ClientV2(enablePathStyle, builder -> { });
}

/** Same as {@link #createS3ClientV2(boolean)}, with {@code overrides} applied after the common settings. */
public S3Client createS3ClientV2(boolean enablePathStyle, Consumer<S3ClientBuilder> overrides) throws Exception {
S3ClientBuilder builder = S3Client.builder();
configureCommon(builder, enablePathStyle);
overrides.accept(builder);
return builder.build();
}

Expand All @@ -88,8 +97,6 @@ public S3AsyncClient createS3AsyncClientV2(boolean enablePathStyle) throws Excep

private <T extends S3BaseClientBuilder<T, ?>> void configureCommon(T builder, boolean enablePathStyle)
throws Exception {
final String accessKey = "user";
final String secretKey = "password";
final Region region = Region.US_EAST_1;

final String protocol;
Expand All @@ -110,7 +117,7 @@ public S3AsyncClient createS3AsyncClientV2(boolean enablePathStyle) throws Excep

LOG.info("S3 Endpoint is {}", endpoint);

AwsBasicCredentials credentials = AwsBasicCredentials.create(accessKey, secretKey);
AwsBasicCredentials credentials = AwsBasicCredentials.create(ACCESS_KEY, SECRET_KEY);

builder.region(region)
.endpointOverride(new URI(endpoint))
Expand Down
Loading