Search in sources :

Example 1 with SdkAsyncHttpClient

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

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWithDefaultsConnectionTtl.

@Test
public void testCreateNettyAsyncHttpClientWithDefaultsConnectionTtl() 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.connectionTtlMillis(), nettyConfiguration.connectionTtlMillis());
}
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 2 with SdkAsyncHttpClient

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

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientTcpKeepAlive.

@Test
public void testCreateNettyAsyncHttpClientTcpKeepAlive() throws Exception {
    boolean tcpKeepAlive = true;
    AttributeMap clientConfiguration = AttributeMap.builder().put(SdkHttpConfigurationOption.TCP_KEEPALIVE, tcpKeepAlive).build();
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(clientConfiguration, builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertEquals(tcpKeepAlive, nettyConfiguration.tcpKeepAlive());
}
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) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 3 with SdkAsyncHttpClient

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

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientConnectionMaxIdleTime.

@Test
public void testCreateNettyAsyncHttpClientConnectionMaxIdleTime() throws Exception {
    Duration maxIdleTime = Duration.ofMillis(2000);
    AttributeMap clientConfiguration = AttributeMap.builder().put(SdkHttpConfigurationOption.CONNECTION_MAX_IDLE_TIMEOUT, maxIdleTime).build();
    NettyNioAsyncHttpClient.Builder builder = NettyNioAsyncHttpClient.builder();
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(clientConfiguration, builder);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertEquals(maxIdleTime.toMillis(), nettyConfiguration.idleTimeoutMillis());
}
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 4 with SdkAsyncHttpClient

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

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWithPropertyReadTimeout.

@Test
public void testCreateNettyAsyncHttpClientWithPropertyReadTimeout() throws Exception {
    int readTimeoutMillis = 45678;
    Properties properties = new Properties();
    properties.setProperty(AWSConfigConstants.HTTP_CLIENT_READ_TIMEOUT_MILLIS, String.valueOf(readTimeoutMillis));
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(properties);
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertEquals(readTimeoutMillis, nettyConfiguration.readTimeoutMillis());
}
Also used : NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with SdkAsyncHttpClient

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

the class AWSGeneralUtilTest method testCreateNettyAsyncHttpClientWithPropertyTcpKeepAlive.

@Test
public void testCreateNettyAsyncHttpClientWithPropertyTcpKeepAlive() throws Exception {
    SdkAsyncHttpClient httpClient = AWSGeneralUtil.createAsyncHttpClient(new Properties());
    NettyConfiguration nettyConfiguration = TestUtil.getNettyConfiguration(httpClient);
    assertTrue(nettyConfiguration.tcpKeepAlive());
}
Also used : NettyConfiguration(software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration) 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