27
27
import io .netty .bootstrap .Bootstrap ;
28
28
import io .netty .channel .Channel ;
29
29
import io .netty .channel .EventLoopGroup ;
30
+ import io .netty .channel .MultiThreadIoEventLoopGroup ;
30
31
import io .netty .channel .socket .DatagramChannel ;
31
32
import 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 ;
37
39
import io .netty .util .concurrent .EventExecutorGroup ;
38
40
import io .netty .util .internal .SystemPropertyUtil ;
39
41
import io .netty .util .internal .logging .InternalLogger ;
40
42
import io .netty .util .internal .logging .InternalLoggerFactory ;
41
43
42
44
/**
43
45
* 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.
45
47
*
46
48
* @author Mark Paluch
47
49
* @since 6.1
@@ -63,7 +65,7 @@ public class IOUringProvider {
63
65
boolean availability ;
64
66
try {
65
67
Class .forName ("io.netty.incubator.channel.uring.IOUring" );
66
- availability = IOUring .isAvailable ();
68
+ availability = IoUring .isAvailable ();
67
69
} catch (ClassNotFoundException e ) {
68
70
availability = false ;
69
71
}
@@ -119,16 +121,16 @@ public static EventLoopResources getResources() {
119
121
*/
120
122
public static void applyKeepAlive (Bootstrap bootstrap , int count , Duration idle , Duration interval ) {
121
123
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 ()));
125
127
}
126
128
127
129
/**
128
130
* Apply TcpUserTimeout options.
129
131
*/
130
132
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 ()));
132
134
}
133
135
134
136
/**
@@ -143,32 +145,35 @@ public boolean matches(Class<? extends EventExecutorGroup> type) {
143
145
144
146
LettuceAssert .notNull (type , "EventLoopGroup type must not be null" );
145
147
146
- return type .equals (eventLoopGroupClass ());
148
+ // In Netty 4.2, IoUringEventLoopGroup doesn't exist, only MultiThreadIoEventLoopGroup
149
+ return type .equals (MultiThreadIoEventLoopGroup .class );
147
150
}
148
151
149
152
@ Override
150
153
public Class <? extends EventLoopGroup > eventLoopGroupClass () {
151
- return IOUringEventLoopGroup .class ;
154
+ // Return the new recommended class, but keep backward compatibility
155
+ return MultiThreadIoEventLoopGroup .class ;
152
156
}
153
157
154
158
@ Override
155
159
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 ());
157
162
}
158
163
159
164
@ Override
160
165
public Class <? extends Channel > socketChannelClass () {
161
- return IOUringSocketChannel .class ;
166
+ return IoUringSocketChannel .class ;
162
167
}
163
168
164
169
@ Override
165
170
public Class <? extends Channel > domainSocketChannelClass () {
166
- return IOUringSocketChannel .class ;
171
+ return IoUringSocketChannel .class ;
167
172
}
168
173
169
174
@ Override
170
175
public Class <? extends DatagramChannel > datagramChannelClass () {
171
- return IOUringDatagramChannel .class ;
176
+ return IoUringDatagramChannel .class ;
172
177
}
173
178
174
179
@ Override
0 commit comments