Search in sources :

Example 6 with TcpTransport

use of org.opensearch.transport.TcpTransport in project OpenSearch by opensearch-project.

the class SimpleNetty4TransportTests method testDefaultKeepAliveSettings.

public void testDefaultKeepAliveSettings() throws IOException {
    assumeTrue("setting default keepalive options not supported on this platform", (IOUtils.LINUX || IOUtils.MAC_OS_X) && JavaVersion.current().compareTo(JavaVersion.parse("11")) >= 0);
    try (MockTransportService serviceC = buildService("TS_C", Version.CURRENT, Settings.EMPTY);
        MockTransportService serviceD = buildService("TS_D", Version.CURRENT, Settings.EMPTY)) {
        serviceC.start();
        serviceC.acceptIncomingRequests();
        serviceD.start();
        serviceD.acceptIncomingRequests();
        try (Transport.Connection connection = serviceC.openConnection(serviceD.getLocalDiscoNode(), TestProfiles.LIGHT_PROFILE)) {
            assertThat(connection, instanceOf(StubbableTransport.WrappedConnection.class));
            Transport.Connection conn = ((StubbableTransport.WrappedConnection) connection).getConnection();
            assertThat(conn, instanceOf(TcpTransport.NodeChannels.class));
            TcpTransport.NodeChannels nodeChannels = (TcpTransport.NodeChannels) conn;
            for (TcpChannel channel : nodeChannels.getChannels()) {
                assertFalse(channel.isServerChannel());
                checkDefaultKeepAliveOptions(channel);
            }
            assertThat(serviceD.getOriginalTransport(), instanceOf(TcpTransport.class));
            for (TcpChannel channel : getAcceptedChannels((TcpTransport) serviceD.getOriginalTransport())) {
                assertTrue(channel.isServerChannel());
                checkDefaultKeepAliveOptions(channel);
            }
        }
    }
}
Also used : MockTransportService(org.opensearch.test.transport.MockTransportService) TcpChannel(org.opensearch.transport.TcpChannel) TcpTransport(org.opensearch.transport.TcpTransport) StubbableTransport(org.opensearch.test.transport.StubbableTransport) Transport(org.opensearch.transport.Transport) TcpTransport(org.opensearch.transport.TcpTransport)

Aggregations

TcpTransport (org.opensearch.transport.TcpTransport)6 Settings (org.opensearch.common.settings.Settings)3 TestThreadPool (org.opensearch.threadpool.TestThreadPool)3 ThreadPool (org.opensearch.threadpool.ThreadPool)3 TransportSettings (org.opensearch.transport.TransportSettings)3 MockTransportService (org.opensearch.test.transport.MockTransportService)2 StubbableTransport (org.opensearch.test.transport.StubbableTransport)2 TcpChannel (org.opensearch.transport.TcpChannel)2 Transport (org.opensearch.transport.Transport)2 NamedWriteableRegistry (org.opensearch.common.io.stream.NamedWriteableRegistry)1 NetworkService (org.opensearch.common.network.NetworkService)1 MockPageCacheRecycler (org.opensearch.common.util.MockPageCacheRecycler)1 PageCacheRecycler (org.opensearch.common.util.PageCacheRecycler)1 NoneCircuitBreakerService (org.opensearch.indices.breaker.NoneCircuitBreakerService)1 SharedGroupFactory (org.opensearch.transport.SharedGroupFactory)1