software.amazon.awssdk.services.s3.S3AsyncClientBuilder Java Examples
The following examples show how to use
software.amazon.awssdk.services.s3.S3AsyncClientBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MirrorImporterConfiguration.java From hedera-mirror-node with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnProperty(prefix = "hedera.mirror.importer.downloader", name = "cloudProvider", havingValue = "GCP") public 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(); }
Example #2
Source File: S3ClientConfiguration.java From tutorials with MIT License | 6 votes |
@Bean public S3AsyncClient s3client(S3ClientConfigurarionProperties s3props, AwsCredentialsProvider credentialsProvider) { SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder() .writeTimeout(Duration.ZERO) .maxConcurrency(64) .build(); S3Configuration serviceConfiguration = S3Configuration.builder() .checksumValidationEnabled(false) .chunkedEncodingEnabled(true) .build(); S3AsyncClientBuilder b = S3AsyncClient.builder() .httpClient(httpClient) .region(s3props.getRegion()) .credentialsProvider(credentialsProvider) .serviceConfiguration(serviceConfiguration); if (s3props.getEndpoint() != null) { b = b.endpointOverride(s3props.getEndpoint()); } return b.build(); }
Example #3
Source File: S3ClientFactory.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Override @Bean(preDestroy = "close") @Singleton @Requires(beans = SdkAsyncHttpClient.class) public S3AsyncClient asyncClient(S3AsyncClientBuilder builder) { return super.asyncClient(builder); }
Example #4
Source File: MirrorImporterConfiguration.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@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(); }
Example #5
Source File: MirrorImporterConfiguration.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
private S3AsyncClientBuilder asyncClientBuilder(String region) { SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder() .maxConcurrency(downloaderProperties.getMaxConcurrency()) .connectionMaxIdleTime(Duration.ofSeconds(5)) // https://github.com/aws/aws-sdk-java-v2/issues/1122 .build(); return S3AsyncClient.builder() .region(Region.of(region)) .credentialsProvider(awsCredentialsProvider( downloaderProperties.getAccessKey(), downloaderProperties.getSecretKey())) .httpClient(httpClient) .overrideConfiguration(c -> c.addExecutionInterceptor(metricsExecutionInterceptor)); }
Example #6
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(S3Config config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { S3AsyncClientBuilder builder = S3AsyncClient.builder(); configureS3Client(builder, config); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #7
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<S3AsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { S3ClientProducer producer = beanContainer.instance(S3ClientProducer.class); producer.setAsyncConfiguredBuilder((S3AsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }
Example #8
Source File: GetBucketPolicyFunctionalTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private S3AsyncClientBuilder getAsyncClientBuilder() { return S3AsyncClient.builder() .region(Region.US_EAST_1) .endpointOverride(HTTP_LOCALHOST_URI) .credentialsProvider( StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"))); }
Example #9
Source File: CompleteMultipartUploadFunctionalTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private S3AsyncClientBuilder getAsyncClientBuilder() { return S3AsyncClient.builder() .region(Region.US_EAST_1) .endpointOverride(HTTP_LOCALHOST_URI) .credentialsProvider( StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"))); }
Example #10
Source File: S3ClientFactory.java From micronaut-aws with Apache License 2.0 | 4 votes |
@Override protected S3AsyncClientBuilder createAsyncBuilder() { return S3AsyncClient.builder() .serviceConfiguration(configuration.getBuilder().build()); }
Example #11
Source File: S3ClientFactory.java From micronaut-aws with Apache License 2.0 | 4 votes |
@Override @Singleton @Requires(beans = SdkAsyncHttpClient.class) public S3AsyncClientBuilder asyncBuilder(SdkAsyncHttpClient httpClient) { return super.asyncBuilder(httpClient); }
Example #12
Source File: S3ClientProducer.java From quarkus with Apache License 2.0 | 4 votes |
public void setAsyncConfiguredBuilder(S3AsyncClientBuilder asyncConfiguredBuilder) { this.asyncConfiguredBuilder = asyncConfiguredBuilder; }