use of org.elasticsearch.http.netty4.Netty4HttpServerTransport in project elasticsearch by elastic.
the class Netty4HttpChannelTests method testReleaseOnSendToClosedChannel.
public void testReleaseOnSendToClosedChannel() {
final Settings settings = Settings.builder().build();
final NamedXContentRegistry registry = xContentRegistry();
try (Netty4HttpServerTransport httpServerTransport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, registry, new NullDispatcher())) {
final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
final EmbeddedChannel embeddedChannel = new EmbeddedChannel();
final Netty4HttpRequest request = new Netty4HttpRequest(registry, httpRequest, embeddedChannel);
final HttpPipelinedRequest pipelinedRequest = randomBoolean() ? new HttpPipelinedRequest(request.request(), 1) : null;
final Netty4HttpChannel channel = new Netty4HttpChannel(httpServerTransport, request, pipelinedRequest, randomBoolean(), threadPool.getThreadContext());
final TestResponse response = new TestResponse(bigArrays);
assertThat(response.content(), instanceOf(Releasable.class));
embeddedChannel.close();
channel.sendResponse(response);
// ESTestCase#after will invoke ensureAllArraysAreReleased which will fail if the response content was not released
}
}
use of org.elasticsearch.http.netty4.Netty4HttpServerTransport in project crate by crate.
the class CrateHttpsTransportTest method testPipelineConfiguration.
@Test
public void testPipelineConfiguration() throws Exception {
Settings settings = Settings.builder().put(PATH_HOME_SETTING.getKey(), "/tmp").put(SslSettings.SSL_HTTP_ENABLED.getKey(), true).put(SslSettings.SSL_TRUSTSTORE_FILEPATH.getKey(), trustStoreFile.getAbsolutePath()).put(SslSettings.SSL_TRUSTSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_FILEPATH.getKey(), keyStoreFile.getAbsolutePath()).put(SslSettings.SSL_KEYSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_KEY_PASSWORD.getKey(), "keystorePassword").build();
NetworkService networkService = new NetworkService(Collections.singletonList(new NetworkService.CustomNameResolver() {
@Override
public InetAddress[] resolveDefault() {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
@Override
public InetAddress[] resolveIfPossible(String value) throws IOException {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
}));
PipelineRegistry pipelineRegistry = new PipelineRegistry(settings);
pipelineRegistry.setSslContextProvider(new SslContextProvider(settings));
Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, BigArrays.NON_RECYCLING_INSTANCE, mock(ThreadPool.class), NamedXContentRegistry.EMPTY, pipelineRegistry, new NettyBootstrap(), mock(NodeClient.class));
EmbeddedChannel channel = new EmbeddedChannel();
try {
transport.start();
Netty4HttpServerTransport.HttpChannelHandler httpChannelHandler = (Netty4HttpServerTransport.HttpChannelHandler) transport.configureServerChannelHandler();
httpChannelHandler.initChannel(channel);
assertThat(channel.pipeline().first(), instanceOf(SslHandler.class));
} finally {
transport.stop();
transport.close();
channel.releaseInbound();
channel.close().awaitUninterruptibly();
}
}
Aggregations