88import io .netty .bootstrap .ServerBootstrap ;
99import io .netty .channel .ChannelOption ;
1010import io .netty .channel .EventLoopGroup ;
11- import io .netty .channel .epoll .Epoll ;
12- import io .netty .channel .epoll .EpollChannelOption ;
13- import io .netty .channel .epoll .EpollEventLoopGroup ;
14- import io .netty .channel .epoll .EpollServerSocketChannel ;
11+ import io .netty .channel .MultiThreadIoEventLoopGroup ;
12+ import io .netty .channel .epoll .*;
1513import io .netty .channel .kqueue .KQueue ;
16- import io .netty .channel .kqueue .KQueueEventLoopGroup ;
14+ import io .netty .channel .kqueue .KQueueChannelOption ;
15+ import io .netty .channel .kqueue .KQueueIoHandler ;
1716import io .netty .channel .kqueue .KQueueServerSocketChannel ;
18- import io .netty .channel .nio .NioEventLoopGroup ;
17+ import io .netty .channel .nio .NioIoHandler ;
1918import io .netty .channel .socket .nio .NioServerSocketChannel ;
20- import io .netty .incubator . channel .uring .IOUring ;
21- import io .netty .incubator . channel .uring .IOUringChannelOption ;
22- import io .netty .incubator . channel .uring .IOUringEventLoopGroup ;
23- import io .netty .incubator . channel .uring .IOUringServerSocketChannel ;
19+ import io .netty .channel .uring .IoUring ;
20+ import io .netty .channel .uring .IoUringChannelOption ;
21+ import io .netty .channel .uring .IoUringIoHandler ;
22+ import io .netty .channel .uring .IoUringServerSocketChannel ;
2423import io .netty .util .concurrent .DefaultThreadFactory ;
2524
2625public abstract class NettyTransport {
@@ -36,7 +35,7 @@ public ServerBootstrap configure(EventLoopGroup acceptor, EventLoopGroup eventlo
3635 public abstract EventLoopGroup createEventLoop (int threads , String threadName , int ioRatio );
3736
3837 public static NettyTransport transport (ClassLoader loader ) {
39- if (isIOUring (loader )) {
38+ if (isIoUring (loader )) {
4039 return ioUring ();
4140 } else if (isEpoll (loader )) {
4241 return epoll ();
@@ -55,13 +54,13 @@ private static NettyTransport epoll() {
5554 }
5655
5756 private static NettyTransport ioUring () {
58- return new IOUringTransport ();
57+ return new IoUringTransport ();
5958 }
6059
61- private static boolean isIOUring (ClassLoader loader ) {
60+ private static boolean isIoUring (ClassLoader loader ) {
6261 try {
63- loader .loadClass ("io.netty.incubator. channel.uring.IOUring " );
64- return IOUring .isAvailable ();
62+ loader .loadClass ("io.netty.channel.uring.IoUring " );
63+ return IoUring .isAvailable ();
6564 } catch (ClassNotFoundException x ) {
6665 return false ;
6766 }
@@ -92,10 +91,8 @@ private static NettyTransport nio() {
9291 private static class JDKTransport extends NettyTransport {
9392 @ Override
9493 public EventLoopGroup createEventLoop (int threads , String threadName , int ioRatio ) {
95- NioEventLoopGroup loopGroup =
96- new NioEventLoopGroup (threads , new DefaultThreadFactory (threadName ));
97- loopGroup .setIoRatio (ioRatio );
98- return loopGroup ;
94+ return new MultiThreadIoEventLoopGroup (
95+ threads , new DefaultThreadFactory (threadName ), NioIoHandler .newFactory ());
9996 }
10097
10198 @ Override
@@ -104,29 +101,29 @@ public ServerBootstrap configure(EventLoopGroup acceptor, EventLoopGroup eventlo
104101 }
105102 }
106103
107- private static class IOUringTransport extends NettyTransport {
104+ private static class IoUringTransport extends NettyTransport {
108105
109106 @ Override
110107 public EventLoopGroup createEventLoop (int threads , String threadName , int ioRatio ) {
111- IOUringEventLoopGroup loopGroup =
112- new IOUringEventLoopGroup (threads , new DefaultThreadFactory (threadName + "-io-uring" ));
113- return loopGroup ;
108+ return new MultiThreadIoEventLoopGroup (
109+ threads ,
110+ new DefaultThreadFactory (threadName + "-io-uring" ),
111+ IoUringIoHandler .newFactory ());
114112 }
115113
116114 @ Override
117115 public ServerBootstrap configure (EventLoopGroup acceptor , EventLoopGroup eventloop ) {
118116 return super .configure (acceptor , eventloop )
119- .channel (IOUringServerSocketChannel .class )
120- .option (IOUringChannelOption .SO_REUSEPORT , true );
117+ .channel (IoUringServerSocketChannel .class )
118+ .option (IoUringChannelOption .SO_REUSEPORT , true );
121119 }
122120 }
123121
124122 private static class EpollTransport extends NettyTransport {
125123 @ Override
126124 public EventLoopGroup createEventLoop (int threads , String threadName , int ioRatio ) {
127- EpollEventLoopGroup loopGroup =
128- new EpollEventLoopGroup (threads , new DefaultThreadFactory (threadName + "-epoll" ));
129- return loopGroup ;
125+ return new MultiThreadIoEventLoopGroup (
126+ threads , new DefaultThreadFactory (threadName + "-epoll" ), EpollIoHandler .newFactory ());
130127 }
131128
132129 @ Override
@@ -140,15 +137,15 @@ public ServerBootstrap configure(EventLoopGroup acceptor, EventLoopGroup eventlo
140137 private static class KQueueTransport extends NettyTransport {
141138 @ Override
142139 public EventLoopGroup createEventLoop (int threads , String threadName , int ioRatio ) {
143- KQueueEventLoopGroup loopGroup =
144- new KQueueEventLoopGroup (threads , new DefaultThreadFactory (threadName + "-kqueue" ));
145- loopGroup .setIoRatio (ioRatio );
146- return loopGroup ;
140+ return new MultiThreadIoEventLoopGroup (
141+ threads , new DefaultThreadFactory (threadName + "-kqueue" ), KQueueIoHandler .newFactory ());
147142 }
148143
149144 @ Override
150145 public ServerBootstrap configure (EventLoopGroup acceptor , EventLoopGroup eventloop ) {
151- return super .configure (acceptor , eventloop ).channel (KQueueServerSocketChannel .class );
146+ return super .configure (acceptor , eventloop )
147+ .channel (KQueueServerSocketChannel .class )
148+ .option (KQueueChannelOption .SO_REUSEPORT , true );
152149 }
153150 }
154151}
0 commit comments