@InterfaceAudience.Private @InterfaceStability.Unstable public class DefaultS3ClientFactory extends org.apache.hadoop.conf.Configured implements S3ClientFactory
S3ClientFactory implementation.
This calls the AWS SDK to configure and create an
AmazonS3Client that communicates with the S3 service.S3ClientFactory.S3ClientCreationParameters| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG
Subclasses refer to this.
|
| Constructor and Description |
|---|
DefaultS3ClientFactory() |
| Modifier and Type | Method and Description |
|---|---|
protected com.amazonaws.services.s3.AmazonS3 |
buildAmazonS3Client(com.amazonaws.ClientConfiguration awsConf,
S3ClientFactory.S3ClientCreationParameters parameters)
Use the Builder API to create an AWS S3 client.
|
protected com.amazonaws.services.s3.AmazonS3 |
buildAmazonS3EncryptionClient(com.amazonaws.ClientConfiguration awsConf,
S3ClientFactory.S3ClientCreationParameters parameters)
Create an
AmazonS3 client of type
AmazonS3EncryptionV2 if CSE is enabled. |
protected static com.amazonaws.services.s3.AmazonS3 |
configureAmazonS3Client(com.amazonaws.services.s3.AmazonS3 s3,
String endPoint,
boolean pathStyleAccess)
Configure classic S3 client.
|
static com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration |
createEndpointConfiguration(String endpoint,
com.amazonaws.ClientConfiguration awsConf,
String awsRegion)
Given an endpoint string, return an endpoint config, or null, if none
is needed.
|
com.amazonaws.services.s3.AmazonS3 |
createS3Client(URI uri,
S3ClientFactory.S3ClientCreationParameters parameters)
Create the client by preparing the AwsConf configuration
and then invoking
buildAmazonS3Client(). |
public com.amazonaws.services.s3.AmazonS3 createS3Client(URI uri, S3ClientFactory.S3ClientCreationParameters parameters) throws IOException
buildAmazonS3Client().createS3Client in interface S3ClientFactoryuri - S3A file system URIparameters - parameter objectIOException - IO problemprotected com.amazonaws.services.s3.AmazonS3 buildAmazonS3EncryptionClient(com.amazonaws.ClientConfiguration awsConf,
S3ClientFactory.S3ClientCreationParameters parameters)
throws IOException
AmazonS3 client of type
AmazonS3EncryptionV2 if CSE is enabled.awsConf - AWS configuration.parameters - parameters.IOException - if lookupPassword() has any problem.protected com.amazonaws.services.s3.AmazonS3 buildAmazonS3Client(com.amazonaws.ClientConfiguration awsConf,
S3ClientFactory.S3ClientCreationParameters parameters)
This has a more complex endpoint configuration mechanism
which initially caused problems; the
withForceGlobalBucketAccessEnabled(true)
command is critical here.
awsConf - AWS configurationparameters - parameterscom.amazonaws.SdkClientException - if the configuration is invalid.protected static com.amazonaws.services.s3.AmazonS3 configureAmazonS3Client(com.amazonaws.services.s3.AmazonS3 s3,
String endPoint,
boolean pathStyleAccess)
throws IllegalArgumentException
This includes: endpoint, Path Access and possibly other options.
s3 - S3 Client.endPoint - s3 endpoint, may be emptypathStyleAccess - enable path style access?IllegalArgumentException - if misconfiguredpublic static com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration createEndpointConfiguration(String endpoint, com.amazonaws.ClientConfiguration awsConf, String awsRegion)
This is a pretty painful piece of code. It is trying to replicate what AwsClient.setEndpoint() does, because you can't call that setter on an AwsClient constructed via the builder, and you can't pass a metrics collector down except through the builder.
Note also that AWS signing is a mystery which nobody fully understands, especially given all problems surface in a "400 bad request" response, which, like all security systems, provides minimal diagnostics out of fear of leaking secrets.
endpoint - possibly null endpoint.awsConf - config to build the URI from.awsRegion - AWS S3 Region if the corresponding config is set.Copyright © 2008–2022 Apache Software Foundation. All rights reserved.