|
@@ -15,6 +15,10 @@ import io.netty.channel.kqueue.KQueue;
|
|
import io.netty.channel.kqueue.KQueueServerSocketChannel;
|
|
import io.netty.channel.kqueue.KQueueServerSocketChannel;
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
|
|
+import io.netty.incubator.channel.uring.IOUring;
|
|
|
|
+import io.netty.incubator.channel.uring.IOUringChannelOption;
|
|
|
|
+import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
|
|
|
|
+import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
|
|
import io.netty.util.ResourceLeakDetector;
|
|
import io.netty.util.ResourceLeakDetector;
|
|
import io.netty.util.ResourceLeakDetector.Level;
|
|
import io.netty.util.ResourceLeakDetector.Level;
|
|
|
|
|
|
@@ -32,8 +36,10 @@ public class HelloWebServer {
|
|
|
|
|
|
public void run() throws Exception {
|
|
public void run() throws Exception {
|
|
// Configure the server.
|
|
// Configure the server.
|
|
-
|
|
|
|
- if (Epoll.isAvailable()) {
|
|
|
|
|
|
+ if (IOUring.isAvailable()) {
|
|
|
|
+ doRun(new IOUringEventLoopGroup(), IOUringServerSocketChannel.class, IoMultiplexer.IO_URING);
|
|
|
|
+ } else
|
|
|
|
+ if (Epoll.isAvailable()) {
|
|
doRun(new EpollEventLoopGroup(), EpollServerSocketChannel.class, IoMultiplexer.EPOLL);
|
|
doRun(new EpollEventLoopGroup(), EpollServerSocketChannel.class, IoMultiplexer.EPOLL);
|
|
} else if (KQueue.isAvailable()) {
|
|
} else if (KQueue.isAvailable()) {
|
|
doRun(new EpollEventLoopGroup(), KQueueServerSocketChannel.class, IoMultiplexer.KQUEUE);
|
|
doRun(new EpollEventLoopGroup(), KQueueServerSocketChannel.class, IoMultiplexer.KQUEUE);
|
|
@@ -45,6 +51,8 @@ public class HelloWebServer {
|
|
private void doRun(EventLoopGroup loupGroup, Class<? extends ServerChannel> serverChannelClass, IoMultiplexer multiplexer) throws InterruptedException {
|
|
private void doRun(EventLoopGroup loupGroup, Class<? extends ServerChannel> serverChannelClass, IoMultiplexer multiplexer) throws InterruptedException {
|
|
try {
|
|
try {
|
|
InetSocketAddress inet = new InetSocketAddress(port);
|
|
InetSocketAddress inet = new InetSocketAddress(port);
|
|
|
|
+
|
|
|
|
+ System.out.printf("Using %s IoMultiplexer%n", multiplexer);
|
|
|
|
|
|
ServerBootstrap b = new ServerBootstrap();
|
|
ServerBootstrap b = new ServerBootstrap();
|
|
|
|
|
|
@@ -52,6 +60,10 @@ public class HelloWebServer {
|
|
b.option(EpollChannelOption.SO_REUSEPORT, true);
|
|
b.option(EpollChannelOption.SO_REUSEPORT, true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (multiplexer == IoMultiplexer.IO_URING) {
|
|
|
|
+ b.option(IOUringChannelOption.SO_REUSEPORT, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
b.option(ChannelOption.SO_BACKLOG, 8192);
|
|
b.option(ChannelOption.SO_BACKLOG, 8192);
|
|
b.option(ChannelOption.SO_REUSEADDR, true);
|
|
b.option(ChannelOption.SO_REUSEADDR, true);
|
|
b.group(loupGroup).channel(serverChannelClass).childHandler(new HelloServerInitializer(loupGroup.next()));
|
|
b.group(loupGroup).channel(serverChannelClass).childHandler(new HelloServerInitializer(loupGroup.next()));
|