2727import io .netty .bootstrap .Bootstrap ;
2828import io .netty .channel .Channel ;
2929import io .netty .channel .EventLoopGroup ;
30+ import io .netty .channel .MultiThreadIoEventLoopGroup ;
3031import io .netty .channel .socket .DatagramChannel ;
3132import io .netty .channel .unix .DomainSocketAddress ;
32- import io .netty .incubator .channel .uring .IOUring ;
33- import io .netty .incubator .channel .uring .IOUringChannelOption ;
34- import io .netty .incubator .channel .uring .IOUringDatagramChannel ;
35- import io .netty .incubator .channel .uring .IOUringEventLoopGroup ;
36- import io .netty .incubator .channel .uring .IOUringSocketChannel ;
33+ import io .netty .channel .uring .IoUring ;
34+ import io .netty .channel .uring .IoUringChannelOption ;
35+ import io .netty .channel .uring .IoUringDatagramChannel ;
36+
37+ import io .netty .channel .uring .IoUringIoHandler ;
38+ import io .netty .channel .uring .IoUringSocketChannel ;
3739import io .netty .util .concurrent .EventExecutorGroup ;
3840import io .netty .util .internal .SystemPropertyUtil ;
3941import io .netty .util .internal .logging .InternalLogger ;
4042import io .netty .util .internal .logging .InternalLoggerFactory ;
4143
4244/**
4345 * Wraps and provides io_uring classes. This is to protect the user from {@link ClassNotFoundException}'s caused by the absence
44- * of the {@literal netty-incubator- transport-native-io_uring} library during runtime. Internal API.
46+ * of the {@literal netty-transport-native-io_uring} library during runtime. Internal API.
4547 *
4648 * @author Mark Paluch
4749 * @since 6.1
@@ -63,7 +65,7 @@ public class IOUringProvider {
6365 boolean availability ;
6466 try {
6567 Class .forName ("io.netty.incubator.channel.uring.IOUring" );
66- availability = IOUring .isAvailable ();
68+ availability = IoUring .isAvailable ();
6769 } catch (ClassNotFoundException e ) {
6870 availability = false ;
6971 }
@@ -119,16 +121,16 @@ public static EventLoopResources getResources() {
119121 */
120122 public static void applyKeepAlive (Bootstrap bootstrap , int count , Duration idle , Duration interval ) {
121123
122- bootstrap .option (IOUringChannelOption .TCP_KEEPCNT , count );
123- bootstrap .option (IOUringChannelOption .TCP_KEEPIDLE , Math .toIntExact (idle .getSeconds ()));
124- bootstrap .option (IOUringChannelOption .TCP_KEEPINTVL , Math .toIntExact (interval .getSeconds ()));
124+ bootstrap .option (IoUringChannelOption .TCP_KEEPCNT , count );
125+ bootstrap .option (IoUringChannelOption .TCP_KEEPIDLE , Math .toIntExact (idle .getSeconds ()));
126+ bootstrap .option (IoUringChannelOption .TCP_KEEPINTVL , Math .toIntExact (interval .getSeconds ()));
125127 }
126128
127129 /**
128130 * Apply TcpUserTimeout options.
129131 */
130132 public static void applyTcpUserTimeout (Bootstrap bootstrap , Duration timeout ) {
131- bootstrap .option (IOUringChannelOption .TCP_USER_TIMEOUT , Math .toIntExact (timeout .toMillis ()));
133+ bootstrap .option (IoUringChannelOption .TCP_USER_TIMEOUT , Math .toIntExact (timeout .toMillis ()));
132134 }
133135
134136 /**
@@ -143,32 +145,35 @@ public boolean matches(Class<? extends EventExecutorGroup> type) {
143145
144146 LettuceAssert .notNull (type , "EventLoopGroup type must not be null" );
145147
146- return type .equals (eventLoopGroupClass ());
148+ // In Netty 4.2, IoUringEventLoopGroup doesn't exist, only MultiThreadIoEventLoopGroup
149+ return type .equals (MultiThreadIoEventLoopGroup .class );
147150 }
148151
149152 @ Override
150153 public Class <? extends EventLoopGroup > eventLoopGroupClass () {
151- return IOUringEventLoopGroup .class ;
154+ // Return the new recommended class, but keep backward compatibility
155+ return MultiThreadIoEventLoopGroup .class ;
152156 }
153157
154158 @ Override
155159 public EventLoopGroup newEventLoopGroup (int nThreads , ThreadFactory threadFactory ) {
156- return new IOUringEventLoopGroup (nThreads , threadFactory );
160+ // Use the new Netty 4.2 approach with IoHandlerFactory
161+ return new MultiThreadIoEventLoopGroup (nThreads , threadFactory , IoUringIoHandler .newFactory ());
157162 }
158163
159164 @ Override
160165 public Class <? extends Channel > socketChannelClass () {
161- return IOUringSocketChannel .class ;
166+ return IoUringSocketChannel .class ;
162167 }
163168
164169 @ Override
165170 public Class <? extends Channel > domainSocketChannelClass () {
166- return IOUringSocketChannel .class ;
171+ return IoUringSocketChannel .class ;
167172 }
168173
169174 @ Override
170175 public Class <? extends DatagramChannel > datagramChannelClass () {
171- return IOUringDatagramChannel .class ;
176+ return IoUringDatagramChannel .class ;
172177 }
173178
174179 @ Override
0 commit comments