Search in sources :

Example 1 with NettyConfiguration

use of software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration 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 NettyConfiguration

use of software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration 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 NettyConfiguration

use of software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration 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 NettyConfiguration

use of software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration 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 NettyConfiguration

use of software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration 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

Test (org.junit.Test)32 NettyConfiguration (software.amazon.awssdk.http.nio.netty.internal.NettyConfiguration)32 SdkAsyncHttpClient (software.amazon.awssdk.http.async.SdkAsyncHttpClient)29 NettyNioAsyncHttpClient (software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient)24 AttributeMap (software.amazon.awssdk.utils.AttributeMap)10 Properties (java.util.Properties)8 Duration (java.time.Duration)5 Protocol (software.amazon.awssdk.http.Protocol)2