Java Code Examples for software.amazon.awssdk.http.async.SdkAsyncHttpClient#Builder

The following examples show how to use software.amazon.awssdk.http.async.SdkAsyncHttpClient#Builder . 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: AbstractAmazonServiceProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
protected void createClientBuilders(List<AmazonClientTransportsBuildItem> clients,
        BuildProducer<AmazonClientBuilderBuildItem> builderProducer,
        Function<RuntimeValue<SdkHttpClient.Builder>, RuntimeValue<AwsClientBuilder>> syncFunc,
        Function<RuntimeValue<SdkAsyncHttpClient.Builder>, RuntimeValue<AwsClientBuilder>> asyncFunc) {

    for (AmazonClientTransportsBuildItem client : clients) {
        if (configName().equals(client.getAwsClientName())) {
            RuntimeValue<AwsClientBuilder> syncBuilder = null;
            RuntimeValue<AwsClientBuilder> asyncBuilder = null;
            if (client.getSyncClassName().isPresent()) {
                syncBuilder = syncFunc.apply(client.getSyncTransport());
            }
            if (client.getAsyncClassName().isPresent()) {
                asyncBuilder = asyncFunc.apply(client.getAsyncTransport());
            }
            builderProducer.produce(new AmazonClientBuilderBuildItem(client.getAwsClientName(), syncBuilder, asyncBuilder));
        }
    }
}
 
Example 2
Source File: KmsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(KmsConfig config,
        RuntimeValue<SdkAsyncHttpClient.Builder> transport) {

    KmsAsyncClientBuilder builder = KmsAsyncClient.builder();
    if (transport != null) {
        builder.httpClientBuilder(transport.getValue());
    }
    return new RuntimeValue<>(builder);
}
 
Example 3
Source File: SesRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(SesConfig config,
        RuntimeValue<SdkAsyncHttpClient.Builder> transport) {

    SesAsyncClientBuilder builder = SesAsyncClient.builder();
    if (transport != null) {
        builder.httpClientBuilder(transport.getValue());
    }
    return new RuntimeValue<>(builder);
}
 
Example 4
Source File: SqsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(SqsConfig config,
        RuntimeValue<SdkAsyncHttpClient.Builder> transport) {

    SqsAsyncClientBuilder builder = SqsAsyncClient.builder();

    if (transport != null) {
        builder.httpClientBuilder(transport.getValue());
    }
    return new RuntimeValue<>(builder);
}
 
Example 5
Source File: SnsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(SnsConfig config,
        RuntimeValue<SdkAsyncHttpClient.Builder> transport) {

    SnsAsyncClientBuilder builder = SnsAsyncClient.builder();

    if (transport != null) {
        builder.httpClientBuilder(transport.getValue());
    }
    return new RuntimeValue<>(builder);
}
 
Example 6
Source File: DynamodbRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(DynamodbConfig config,
        RuntimeValue<SdkAsyncHttpClient.Builder> transport) {

    DynamoDbAsyncClientBuilder builder = DynamoDbAsyncClient.builder();
    builder.endpointDiscoveryEnabled(config.enableEndpointDiscovery);

    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 vote down vote up
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 8
Source File: AmazonClientTransportsBuildItem.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public AmazonClientTransportsBuildItem(Optional<DotName> syncClassName, Optional<DotName> asyncClassName,
        RuntimeValue<Builder> syncTransport,
        RuntimeValue<SdkAsyncHttpClient.Builder> asyncTransport,
        String awsClientName) {
    this.syncClassName = syncClassName;
    this.asyncClassName = asyncClassName;
    this.syncTransport = syncTransport;
    this.asyncTransport = asyncTransport;
    this.awsClientName = awsClientName;
}
 
Example 9
Source File: ResourceManagementTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void asyncHttpClientFromBuilderShutdown() {
    SdkAsyncHttpClient httpClient = mock(SdkAsyncHttpClient.class);
    SdkAsyncHttpClient.Builder httpClientBuilder = mock(SdkAsyncHttpClient.Builder.class);

    when(httpClientBuilder.buildWithDefaults(any())).thenReturn(httpClient);

    asyncClientBuilder().httpClientBuilder(httpClientBuilder).build().close();
    verify(httpClient).close();
}
 
Example 10
Source File: AmazonClientTransportsBuildItem.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<SdkAsyncHttpClient.Builder> getAsyncTransport() {
    return asyncTransport;
}
 
Example 11
Source File: AmazonClientTransportRecorder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<SdkAsyncHttpClient.Builder> configureAsync(String clientName,
        RuntimeValue<NettyHttpClientConfig> asyncConfigRuntime) {
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    NettyHttpClientConfig asyncConfig = asyncConfigRuntime.getValue();
    validateNettyClientConfig(clientName, asyncConfig);

    builder.connectionAcquisitionTimeout(asyncConfig.connectionAcquisitionTimeout);
    builder.connectionMaxIdleTime(asyncConfig.connectionMaxIdleTime);
    builder.connectionTimeout(asyncConfig.connectionTimeout);
    asyncConfig.connectionTimeToLive.ifPresent(builder::connectionTimeToLive);
    builder.maxConcurrency(asyncConfig.maxConcurrency);
    builder.maxPendingConnectionAcquires(asyncConfig.maxPendingConnectionAcquires);
    builder.protocol(asyncConfig.protocol);
    builder.readTimeout(asyncConfig.readTimeout);
    builder.writeTimeout(asyncConfig.writeTimeout);
    asyncConfig.sslProvider.ifPresent(builder::sslProvider);
    builder.useIdleConnectionReaper(asyncConfig.useIdleConnectionReaper);

    if (asyncConfig.http2.initialWindowSize.isPresent() || asyncConfig.http2.maxStreams.isPresent()) {
        Http2Configuration.Builder http2Builder = Http2Configuration.builder();
        asyncConfig.http2.initialWindowSize.ifPresent(http2Builder::initialWindowSize);
        asyncConfig.http2.maxStreams.ifPresent(http2Builder::maxStreams);
        asyncConfig.http2.healthCheckPingPeriod.ifPresent(http2Builder::healthCheckPingPeriod);
        builder.http2Configuration(http2Builder.build());
    }

    if (asyncConfig.proxy.enabled && asyncConfig.proxy.endpoint.isPresent()) {
        software.amazon.awssdk.http.nio.netty.ProxyConfiguration.Builder proxyBuilder = software.amazon.awssdk.http.nio.netty.ProxyConfiguration
                .builder().scheme(asyncConfig.proxy.endpoint.get().getScheme())
                .host(asyncConfig.proxy.endpoint.get().getHost())
                .nonProxyHosts(new HashSet<>(asyncConfig.proxy.nonProxyHosts.orElse(Collections.emptyList())));

        if (asyncConfig.proxy.endpoint.get().getPort() != -1) {
            proxyBuilder.port(asyncConfig.proxy.endpoint.get().getPort());
        }
        builder.proxyConfiguration(proxyBuilder.build());
    }

    getTlsKeyManagersProvider(asyncConfig.tlsManagersProvider).ifPresent(builder::tlsKeyManagersProvider);

    if (asyncConfig.eventLoop.override) {
        SdkEventLoopGroup.Builder eventLoopBuilder = SdkEventLoopGroup.builder();
        asyncConfig.eventLoop.numberOfThreads.ifPresent(eventLoopBuilder::numberOfThreads);
        if (asyncConfig.eventLoop.threadNamePrefix.isPresent()) {
            eventLoopBuilder.threadFactory(
                    new ThreadFactoryBuilder().threadNamePrefix(asyncConfig.eventLoop.threadNamePrefix.get()).build());
        }
        builder.eventLoopGroupBuilder(eventLoopBuilder);
    }

    return new RuntimeValue<>(builder);
}
 
Example 12
Source File: NettySdkAsyncHttpService.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public SdkAsyncHttpClient.Builder createAsyncHttpClientFactory() {
    return NettyNioAsyncHttpClient.builder();
}
 
Example 13
Source File: SdkDefaultClientBuilder.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@SdkTestInternalApi
protected SdkDefaultClientBuilder(SdkHttpClient.Builder defaultHttpClientBuilder,
                                  SdkAsyncHttpClient.Builder defaultAsyncHttpClientBuilder) {
    this.defaultHttpClientBuilder = defaultHttpClientBuilder;
    this.defaultAsyncHttpClientBuilder = defaultAsyncHttpClientBuilder;
}
 
Example 14
Source File: AwsDefaultClientBuilder.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@SdkTestInternalApi
AwsDefaultClientBuilder(SdkHttpClient.Builder defaultHttpClientBuilder,
                        SdkAsyncHttpClient.Builder defaultAsyncHttpClientFactory) {
    super(defaultHttpClientBuilder, defaultAsyncHttpClientFactory);
}