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);
}
}
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;
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations