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();
}
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;
}
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();
}
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();
}
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();
}
Aggregations