Search in sources :

Example 1 with S3AsyncClientBuilder

use of software.amazon.awssdk.services.s3.S3AsyncClientBuilder in project trino by trinodb.

the class S3FileSystemExchangeStorage method createS3AsyncClient.

private S3AsyncClient createS3AsyncClient(AwsCredentialsProvider credentialsProvider, ClientOverrideConfiguration overrideConfig) {
    S3AsyncClientBuilder clientBuilder = S3AsyncClient.builder().credentialsProvider(credentialsProvider).overrideConfiguration(overrideConfig);
    region.ifPresent(clientBuilder::region);
    endpoint.ifPresent(s3Endpoint -> clientBuilder.endpointOverride(URI.create(s3Endpoint)));
    return clientBuilder.build();
}
Also used : S3AsyncClientBuilder(software.amazon.awssdk.services.s3.S3AsyncClientBuilder)

Example 2 with S3AsyncClientBuilder

use of software.amazon.awssdk.services.s3.S3AsyncClientBuilder in project imageio-ext by geosolutions-it.

the class S3ClientFactory method getS3Client.

public static S3AsyncClient getS3Client(S3ConfigurationProperties configProps) {
    String region = configProps.getRegion();
    if (s3AsyncClients.containsKey(region)) {
        return s3AsyncClients.get(region);
    }
    S3AsyncClientBuilder builder = S3AsyncClient.builder();
    if (configProps.getUser() != null || configProps.getPassword() != null) {
        builder.credentialsProvider(() -> AwsBasicCredentials.create(configProps.getUser(), configProps.getPassword()));
    } else {
        builder.credentialsProvider(() -> AnonymousCredentialsProvider.create().resolveCredentials());
    }
    if (configProps.getEndpoint() != null) {
        String endpoint = configProps.getEndpoint();
        if (!endpoint.endsWith("/")) {
            endpoint = endpoint + "/";
        }
        builder.endpointOverride(URI.create(endpoint));
    }
    if (configProps.getRegion() != null) {
        builder.region(Region.of(configProps.getRegion()));
    }
    // configure executor / thread pool
    builder.asyncConfiguration(b -> b.advancedOption(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR, getExecutor(configProps)));
    S3AsyncClient s3AsyncClient = builder.build();
    s3AsyncClients.put(region, s3AsyncClient);
    return s3AsyncClient;
}
Also used : S3AsyncClientBuilder(software.amazon.awssdk.services.s3.S3AsyncClientBuilder) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient)

Example 3 with S3AsyncClientBuilder

use of software.amazon.awssdk.services.s3.S3AsyncClientBuilder in project hedera-mirror-node by hashgraph.

the class CloudStorageConfiguration method gcpCloudStorageClient.

@Bean
@ConditionalOnProperty(prefix = "hedera.mirror.importer.downloader", name = "cloudProvider", havingValue = "GCP")
S3AsyncClient gcpCloudStorageClient() {
    log.info("Configured to download from GCP with bucket name '{}'", downloaderProperties.getBucketName());
    // Any valid region for aws client. Ignored by GCP.
    S3AsyncClientBuilder clientBuilder = asyncClientBuilder("us-east-1").endpointOverride(URI.create(downloaderProperties.getCloudProvider().getEndpoint()));
    String projectId = downloaderProperties.getGcpProjectId();
    if (StringUtils.isNotBlank(projectId)) {
        clientBuilder.overrideConfiguration(builder -> builder.addExecutionInterceptor(new ExecutionInterceptor() {

            @Override
            public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
                return context.httpRequest().toBuilder().appendRawQueryParameter("userProject", projectId).build();
            }
        }));
    }
    return clientBuilder.build();
}
Also used : ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) S3AsyncClientBuilder(software.amazon.awssdk.services.s3.S3AsyncClientBuilder) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 4 with S3AsyncClientBuilder

use of software.amazon.awssdk.services.s3.S3AsyncClientBuilder in project hedera-mirror-node by hashgraph.

the class CloudStorageConfiguration method s3CloudStorageClient.

@Bean
@ConditionalOnProperty(prefix = "hedera.mirror.importer.downloader", name = "cloudProvider", havingValue = "S3", matchIfMissing = true)
public S3AsyncClient s3CloudStorageClient() {
    log.info("Configured to download from S3 in region {} with bucket name '{}'", downloaderProperties.getRegion(), downloaderProperties.getBucketName());
    S3AsyncClientBuilder clientBuilder = asyncClientBuilder(downloaderProperties.getRegion());
    String endpointOverride = downloaderProperties.getEndpointOverride();
    if (endpointOverride != null) {
        log.info("Overriding s3 client endpoint to {}", endpointOverride);
        clientBuilder.endpointOverride(URI.create(endpointOverride));
    }
    return clientBuilder.build();
}
Also used : S3AsyncClientBuilder(software.amazon.awssdk.services.s3.S3AsyncClientBuilder) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 5 with S3AsyncClientBuilder

use of software.amazon.awssdk.services.s3.S3AsyncClientBuilder in project DataSpaceConnector by eclipse-dataspaceconnector.

the class SdkClientBuilders method buildS3Client.

public static S3AsyncClient buildS3Client(Consumer<S3AsyncClientBuilder> consumer, ThreadPoolExecutor executor, AwsCredentialsProvider credentialsProvider) {
    S3AsyncClientBuilder builder = S3AsyncClient.builder();
    builder.asyncConfiguration(b -> b.advancedOption(FUTURE_COMPLETION_EXECUTOR, executor));
    builder.credentialsProvider(credentialsProvider);
    consumer.accept(builder);
    return builder.build();
}
Also used : S3AsyncClientBuilder(software.amazon.awssdk.services.s3.S3AsyncClientBuilder)

Aggregations

S3AsyncClientBuilder (software.amazon.awssdk.services.s3.S3AsyncClientBuilder)9 StrictYamlMapping (com.amihaiemil.eoyaml.StrictYamlMapping)2 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)2 Bean (org.springframework.context.annotation.Bean)2 EachBean (io.micronaut.context.annotation.EachBean)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1 Singleton (javax.inject.Singleton)1 ExecutionAttributes (software.amazon.awssdk.core.interceptor.ExecutionAttributes)1 ExecutionInterceptor (software.amazon.awssdk.core.interceptor.ExecutionInterceptor)1 S3AsyncClient (software.amazon.awssdk.services.s3.S3AsyncClient)1