HttpNativeServer Class — netty Architecture
Architecture documentation for the HttpNativeServer class in HttpNativeServer.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3b94d628_ec03_4964_2e12_08b49e8b8b30["HttpNativeServer"] ce883617_5e5c_f30c_d260_2165ecb014dd["HttpNativeServer.java"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|defined in| ce883617_5e5c_f30c_d260_2165ecb014dd 0746b318_5e34_2aea_11ca_52a17b2dac86["HttpNativeServer()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| 0746b318_5e34_2aea_11ca_52a17b2dac86 45f1144f_5b41_1877_954c_568d5cc6d1c4["main()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| 45f1144f_5b41_1877_954c_568d5cc6d1c4 f6ad4c3c_5e38_b874_f209_c0cafcbf4077["testTransport()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| f6ad4c3c_5e38_b874_f209_c0cafcbf4077 8536a63d_2189_76eb_a356_d4a99e4d4b1e["IoHandlerFactory()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| 8536a63d_2189_76eb_a356_d4a99e4d4b1e 8c1175d6_6741_a9f5_413e_017458549e56["ByteBufAllocator()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| 8c1175d6_6741_a9f5_413e_017458549e56 96e01bcf_bb4e_5979_6c50_313f5fa240b5["chooseServerChannelClass()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| 96e01bcf_bb4e_5979_6c50_313f5fa240b5 c11a7e9d_4a3b_6ccd_5b4d_c1a8a682fae4["chooseChannelClass()"] 3b94d628_ec03_4964_2e12_08b49e8b8b30 -->|method| c11a7e9d_4a3b_6ccd_5b4d_c1a8a682fae4
Relationship Graph
Source Code
testsuite-native-image/src/main/java/io/netty/testsuite/svm/HttpNativeServer.java lines 55–183
public final class HttpNativeServer {
/**
* Main entry point (not instantiable)
*/
private HttpNativeServer() {
}
public static void main(String[] args) throws Exception {
for (TransportType value : TransportType.values()) {
for (AllocatorType allocatorType : AllocatorType.values()) {
boolean serverStartSucess = testTransport(value, allocatorType);
System.out.println("Server started with transport type " + value + ": " + serverStartSucess);
if (!serverStartSucess) {
System.exit(1);
}
}
}
// return the right system exit code to signal success
System.exit(0);
}
public static boolean testTransport(TransportType ioType, AllocatorType allocatorType) throws Exception {
// Configure the server.
EventLoopGroup group = new MultiThreadIoEventLoopGroup(chooseFactory(ioType));
// Control status.
boolean serverStartSucess = false;
try {
CompletableFuture<Void> httpRequestFuture = new CompletableFuture<>();
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(group)
.channel(chooseServerChannelClass(ioType))
.handler(new LoggingHandler(LogLevel.INFO))
.childOption(ChannelOption.ALLOCATOR, chooseAllocator(allocatorType))
.childHandler(new HttpNativeServerInitializer(httpRequestFuture));
Channel channel = b.bind(0).sync().channel();
System.err.println("Server started, will shutdown now.");
Channel httpClient = new HttpNativeClient(
((InetSocketAddress) channel.localAddress()).getPort(),
group, chooseChannelClass(ioType)
).initClient();
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/hello");
httpClient.writeAndFlush(request).sync();
httpRequestFuture.get();
channel.close().sync();
httpClient.close().sync();
serverStartSucess = true;
} finally {
group.shutdownGracefully();
}
return serverStartSucess;
}
public static IoHandlerFactory chooseFactory(TransportType ioType) {
if (ioType == TransportType.EPOLL) {
return EpollIoHandler.newFactory();
}
if (ioType == TransportType.IO_URING) {
IoUringIoHandlerConfig config = new IoUringIoHandlerConfig();
if (IoUring.isRegisterBufferRingSupported()) {
config.setBufferRingConfig(
IoUringBufferRingConfig.builder()
.bufferGroupId((short) 0)
.bufferRingSize((short) 16)
.batchSize(16)
.allocator(new IoUringFixedBufferRingAllocator(1024))
.batchAllocation(false)
.build()
);
}
return IoUringIoHandler.newFactory(config);
}
Source
Frequently Asked Questions
What is the HttpNativeServer class?
HttpNativeServer is a class in the netty codebase, defined in testsuite-native-image/src/main/java/io/netty/testsuite/svm/HttpNativeServer.java.
Where is HttpNativeServer defined?
HttpNativeServer is defined in testsuite-native-image/src/main/java/io/netty/testsuite/svm/HttpNativeServer.java at line 55.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free