Search in sources :

Example 1 with TcpTransport

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

the class NettyTransportMultiPortTests method testThatNettyCanBindToMultiplePorts.

public void testThatNettyCanBindToMultiplePorts() throws Exception {
    Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), // will not actually bind to this
    22).put("transport.profiles.default.port", 0).put("transport.profiles.client1.port", 0).build();
    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport transport = startTransport(settings, threadPool)) {
        assertEquals(1, transport.profileBoundAddresses().size());
        assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
        terminate(threadPool);
    }
}
Also used : ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) TcpTransport(org.opensearch.transport.TcpTransport) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Settings(org.opensearch.common.settings.Settings) TransportSettings(org.opensearch.transport.TransportSettings)

Example 2 with TcpTransport

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

the class NettyTransportMultiPortTests method startTransport.

private TcpTransport startTransport(Settings settings, ThreadPool threadPool) {
    PageCacheRecycler recycler = new MockPageCacheRecycler(Settings.EMPTY);
    TcpTransport transport = new Netty4Transport(settings, Version.CURRENT, threadPool, new NetworkService(Collections.emptyList()), recycler, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService(), new SharedGroupFactory(settings));
    transport.start();
    assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
    return transport;
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) PageCacheRecycler(org.opensearch.common.util.PageCacheRecycler) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) TcpTransport(org.opensearch.transport.TcpTransport) NetworkService(org.opensearch.common.network.NetworkService) SharedGroupFactory(org.opensearch.transport.SharedGroupFactory) NoneCircuitBreakerService(org.opensearch.indices.breaker.NoneCircuitBreakerService)

Example 3 with TcpTransport

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

the class SimpleNioTransportTests 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)

Example 4 with TcpTransport

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

the class NettyTransportMultiPortTests method testThatDefaultProfileInheritsFromStandardSettings.

public void testThatDefaultProfileInheritsFromStandardSettings() throws Exception {
    Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), 0).put("transport.profiles.client1.port", 0).build();
    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport transport = startTransport(settings, threadPool)) {
        assertEquals(1, transport.profileBoundAddresses().size());
        assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
        terminate(threadPool);
    }
}
Also used : ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) TcpTransport(org.opensearch.transport.TcpTransport) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Settings(org.opensearch.common.settings.Settings) TransportSettings(org.opensearch.transport.TransportSettings)

Example 5 with TcpTransport

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

the class NettyTransportMultiPortTests method testThatDefaultProfilePortOverridesGeneralConfiguration.

public void testThatDefaultProfilePortOverridesGeneralConfiguration() throws Exception {
    Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), // will not actually bind to this
    22).put("transport.profiles.default.port", 0).build();
    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport transport = startTransport(settings, threadPool)) {
        assertEquals(0, transport.profileBoundAddresses().size());
        assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
        terminate(threadPool);
    }
}
Also used : ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) TcpTransport(org.opensearch.transport.TcpTransport) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Settings(org.opensearch.common.settings.Settings) TransportSettings(org.opensearch.transport.TransportSettings)

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