Search in sources :

Example 11 with SdkAsyncHttpClient

use of software.amazon.awssdk.http.async.SdkAsyncHttpClient in project flink by apache.

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWriteTimeout.

@Test
public void testCreateNettyAsyncHttpClientWriteTimeout() throws Exception {
    Duration writeTimeout = Duration.ofMillis(3000);
    AttributeMap clientConfiguration = AttributeMap.builder().put(SdkHttpConfigurationOption.WRITE_TIMEOUT, writeTimeout).build();
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(clientConfiguration, builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertEquals(writeTimeout.toMillis(), nettyConfiguration.writeTimeoutMillis());
}
Also used : AttributeMap(software.amazon.awssdk.utils.AttributeMap) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) Duration(java.time.Duration) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 12 with SdkAsyncHttpClient

use of software.amazon.awssdk.http.async.SdkAsyncHttpClient in project flink by apache.

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWithDefaultsTlsKeyManagersProvider.

@Test
public void testCreateNettyAsyncHttpClientWithDefaultsTlsKeyManagersProvider() throws Exception {
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    SdkAsyncHttpClient httpDefaultClient = NettyNioAsyncHttpClient.create();
    NettyConfiguration nettyDefaultConfiguration = TestUtil.getNettyConfiguration(httpDefaultClient);
    assertEquals(nettyDefaultConfiguration.tlsKeyManagersProvider(), nettyConfiguration.tlsKeyManagersProvider());
}
Also used : NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 13 with SdkAsyncHttpClient

use of software.amazon.awssdk.http.async.SdkAsyncHttpClient in project flink by apache.

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientReadTimeout.

@Test
public void testCreateNettyAsyncHttpClientReadTimeout() throws Exception {
    Duration readTimeout = Duration.ofMillis(1234);
    AttributeMap clientConfiguration = AttributeMap.builder().put(SdkHttpConfigurationOption.READ_TIMEOUT, readTimeout).build();
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(clientConfiguration, builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertEquals(readTimeout.toMillis(), nettyConfiguration.readTimeoutMillis());
}
Also used : AttributeMap(software.amazon.awssdk.utils.AttributeMap) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) Duration(java.time.Duration) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 14 with SdkAsyncHttpClient

use of software.amazon.awssdk.http.async.SdkAsyncHttpClient in project flink by apache.

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWithDefaultsConnectionTimeout.

@Test
public void testCreateNettyAsyncHttpClientWithDefaultsConnectionTimeout() throws Exception {
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    SdkAsyncHttpClient httpDefaultClient = NettyNioAsyncHttpClient.create();
    NettyConfiguration nettyDefaultConfiguration = TestUtil.getNettyConfiguration(httpDefaultClient);
    assertEquals(nettyDefaultConfiguration.connectTimeoutMillis(), nettyConfiguration.connectTimeoutMillis());
}
Also used : NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 15 with SdkAsyncHttpClient

use of software.amazon.awssdk.http.async.SdkAsyncHttpClient in project flink by apache.

the class AWSAsyncSinkUtilTest method testCreateKinesisAsyncClient.

@Test
public void testCreateKinesisAsyncClient() {
    Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
    MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
    ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().build();
    SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().build();
    AWSAsyncSinkUtil.createAwsAsyncClient(properties, builder, httpClient, clientOverrideConfiguration);
    verify(builder).overrideConfiguration(clientOverrideConfiguration);
    verify(builder).httpClient(httpClient);
    verify(builder).region(Region.of("eu-west-2"));
    verify(builder).credentialsProvider(argThat(cp -> cp instanceof DefaultCredentialsProvider));
    verify(builder, never()).endpointOverride(any());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) AwsAsyncClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) SdkAdvancedClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) Duration(java.time.Duration) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) URI(java.net.URI) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Region(software.amazon.awssdk.regions.Region) ClientAsyncConfiguration(software.amazon.awssdk.core.client.config.ClientAsyncConfiguration) Properties(java.util.Properties) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) Mockito.verify(org.mockito.Mockito.verify) AWS_REGION(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_REGION) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) Mockito.never(org.mockito.Mockito.never) SdkClient(software.amazon.awssdk.core.SdkClient) AWS_ENDPOINT(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_ENDPOINT) AWSAsyncSinkUtil.formatFlinkUserAgentPrefix(org.apache.flink.connector.aws.util.AWSAsyncSinkUtil.formatFlinkUserAgentPrefix) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) Mockito.mock(org.mockito.Mockito.mock) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

SdkAsyncHttpClient (software.amazon.awssdk.http.async.SdkAsyncHttpClient)39 Test (org.junit.Test)37 NettyConfiguration (software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration)29 NettyNioAsyncHttpClient (software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient)25 AttributeMap (software.amazon.awssdk.utils.AttributeMap)11 Properties (java.util.Properties)8 Duration (java.time.Duration)6 Segment (com.amazonaws.xray.entities.Segment)5 Subsegment (com.amazonaws.xray.entities.Subsegment)5 Map (java.util.Map)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 LambdaAsyncClient (software.amazon.awssdk.services.lambda.LambdaAsyncClient)5 Cause (com.amazonaws.xray.entities.Cause)4 ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)3 KinesisAsyncClient (software.amazon.awssdk.services.kinesis.KinesisAsyncClient)3 URI (java.net.URI)2 Mockito.never (org.mockito.Mockito.never)2 Mockito.verify (org.mockito.Mockito.verify)2 Mockito.when (org.mockito.Mockito.when)2 AWSXRay (com.amazonaws.xray.AWSXRay)1