Skip to content

Commit a7aedda

Browse files
committed
Support Unix Domain Sockets with io_uring transport
In Netty 4.2, Unix Domain Sockets with io_uring are supported. But they were not integrated by Vert.x yet. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 027014f commit a7aedda

4 files changed

Lines changed: 56 additions & 32 deletions

File tree

.github/workflows/ci-matrix-5.x.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
- os: ubuntu-latest
2222
jdk: 11
2323
profile: '-PNativeEpoll+DomainSockets'
24+
- os: ubuntu-latest
25+
jdk: 11
26+
profile: '-PNativeIoUring+DomainSockets'
2427
- os: ubuntu-latest
2528
jdk: 25
2629
- os: windows-2022

vertx-core/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,29 @@
780780
</properties>
781781
</profile>
782782

783+
<profile>
784+
<id>NativeIoUring+DomainSockets</id>
785+
<properties>
786+
<vertx.surefire.nettyTransport>io_uring</vertx.surefire.nettyTransport>
787+
<vertx.surefire.useDomainSockets>true</vertx.surefire.useDomainSockets>
788+
<vertx.surefire.useModulePath>false</vertx.surefire.useModulePath>
789+
</properties>
790+
<build>
791+
<plugins>
792+
<plugin>
793+
<groupId>org.apache.maven.plugins</groupId>
794+
<artifactId>maven-surefire-plugin</artifactId>
795+
<configuration>
796+
<!-- TODO: enable all tests later when NativeIoUring profile is re-enabled in CI -->
797+
<test>
798+
io.vertx.tests.net.NetBandwidthLimitingTest,io.vertx.tests.net.NetTest#testListenDomainSocketAddressNative,HttpDomainSocketTest#testListenDomainSocketAddressNative,
799+
</test>
800+
</configuration>
801+
</plugin>
802+
</plugins>
803+
</build>
804+
</profile>
805+
783806
<profile>
784807
<id>NativeKQueue</id>
785808
<properties>

vertx-core/src/main/java/io/vertx/core/impl/transports/IoUringTransport.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -12,7 +12,10 @@
1212

1313
import io.netty.bootstrap.Bootstrap;
1414
import io.netty.bootstrap.ServerBootstrap;
15-
import io.netty.channel.*;
15+
import io.netty.channel.Channel;
16+
import io.netty.channel.ChannelFactory;
17+
import io.netty.channel.IoHandlerFactory;
18+
import io.netty.channel.ServerChannel;
1619
import io.netty.channel.socket.DatagramChannel;
1720
import io.netty.channel.socket.InternetProtocolFamily;
1821
import io.netty.channel.unix.DomainSocketAddress;
@@ -57,7 +60,7 @@ public IoUringTransport() {
5760

5861
@Override
5962
public boolean supportsDomainSockets() {
60-
return false;
63+
return true;
6164
}
6265

6366
@Override
@@ -68,7 +71,7 @@ public boolean supportFileRegion() {
6871
@Override
6972
public SocketAddress convert(io.vertx.core.net.SocketAddress address) {
7073
if (address.isDomainSocket()) {
71-
throw new IllegalArgumentException("Domain socket not supported by IOUring transport");
74+
return new DomainSocketAddress(address.path());
7275
}
7376
return Transport.super.convert(address);
7477
}
@@ -109,15 +112,15 @@ public ChannelFactory<? extends DatagramChannel> datagramChannelFactory() {
109112
@Override
110113
public ChannelFactory<? extends Channel> channelFactory(boolean domainSocket) {
111114
if (domainSocket) {
112-
throw new IllegalArgumentException();
115+
return IoUringDomainSocketChannel::new;
113116
}
114117
return IoUringSocketChannel::new;
115118
}
116119

117120
@Override
118121
public ChannelFactory<? extends ServerChannel> serverChannelFactory(boolean domainSocket) {
119122
if (domainSocket) {
120-
throw new IllegalArgumentException();
123+
return IoUringServerDomainSocketChannel::new;
121124
}
122125
return IoUringServerSocketChannel::new;
123126
}
@@ -131,7 +134,9 @@ public void configure(DatagramChannel channel, DatagramSocketOptions options) {
131134
@Override
132135
public void configure(TcpConfig options, boolean domainSocket, ServerBootstrap bootstrap) {
133136
if (domainSocket) {
134-
throw new IllegalArgumentException();
137+
// Domain sockets don't support TCP-specific options
138+
Transport.super.configure(options, domainSocket, bootstrap);
139+
return;
135140
}
136141
bootstrap.option(IoUringChannelOption.SO_REUSEPORT, options.isReusePort());
137142
if (options.isTcpFastOpen()) {
@@ -140,20 +145,22 @@ public void configure(TcpConfig options, boolean domainSocket, ServerBootstrap b
140145
bootstrap.childOption(IoUringChannelOption.TCP_USER_TIMEOUT, options.getTcpUserTimeout());
141146
bootstrap.childOption(IoUringChannelOption.TCP_QUICKACK, options.isTcpQuickAck());
142147
bootstrap.childOption(IoUringChannelOption.TCP_CORK, options.isTcpCork());
143-
Transport.super.configure(options, false, bootstrap);
148+
Transport.super.configure(options, domainSocket, bootstrap);
144149
}
145150

146151
@Override
147152
public void configure(TcpConfig options, boolean domainSocket, Bootstrap bootstrap) {
148153
if (domainSocket) {
149-
throw new IllegalArgumentException();
154+
// Domain sockets don't support TCP-specific options
155+
Transport.super.configure(options, domainSocket, bootstrap);
156+
return;
150157
}
151158
if (options.isTcpFastOpen()) {
152159
bootstrap.option(IoUringChannelOption.TCP_FASTOPEN_CONNECT, options.isTcpFastOpen());
153160
}
154161
bootstrap.option(IoUringChannelOption.TCP_USER_TIMEOUT, options.getTcpUserTimeout());
155162
bootstrap.option(IoUringChannelOption.TCP_QUICKACK, options.isTcpQuickAck());
156163
bootstrap.option(IoUringChannelOption.TCP_CORK, options.isTcpCork());
157-
Transport.super.configure(options, false, bootstrap);
164+
Transport.super.configure(options, domainSocket, bootstrap);
158165
}
159166
}

vertx-core/src/test/java/io/vertx/tests/net/NetBandwidthLimitingTest.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111

1212
package io.vertx.tests.net;
1313

14+
import io.vertx.core.AbstractVerticle;
15+
import io.vertx.core.DeploymentOptions;
16+
import io.vertx.core.Future;
17+
import io.vertx.core.Promise;
18+
import io.vertx.core.buffer.Buffer;
19+
import io.vertx.core.net.*;
20+
import io.vertx.test.core.TestUtils;
21+
import io.vertx.test.core.VertxTestBase;
22+
import org.junit.Assert;
23+
import org.junit.Rule;
24+
import org.junit.Test;
25+
import org.junit.rules.TemporaryFolder;
26+
1427
import java.io.BufferedWriter;
1528
import java.io.File;
1629
import java.io.FileOutputStream;
@@ -23,19 +36,6 @@
2336
import java.util.concurrent.TimeUnit;
2437
import java.util.concurrent.atomic.AtomicLong;
2538

26-
import io.vertx.core.net.*;
27-
import io.vertx.core.transport.Transport;
28-
import org.junit.*;
29-
import org.junit.rules.TemporaryFolder;
30-
31-
import io.vertx.core.AbstractVerticle;
32-
import io.vertx.core.DeploymentOptions;
33-
import io.vertx.core.Future;
34-
import io.vertx.core.Promise;
35-
import io.vertx.core.buffer.Buffer;
36-
import io.vertx.test.core.TestUtils;
37-
import io.vertx.test.core.VertxTestBase;
38-
3939
import static io.vertx.core.net.NetServerOptions.DEFAULT_PORT;
4040

4141
public class NetBandwidthLimitingTest extends VertxTestBase {
@@ -84,7 +84,6 @@ protected void tearDown() throws Exception {
8484

8585
@Test
8686
public void sendBufferThrottled() {
87-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
8887
long startTime = System.nanoTime();
8988

9089
Buffer expected = TestUtils.randomBuffer(64 * 1024 * 4);
@@ -117,7 +116,6 @@ public void sendBufferThrottled() {
117116

118117
@Test
119118
public void sendFileIsThrottled() throws Exception {
120-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
121119
long startTime = System.nanoTime();
122120

123121
File fDir = testFolder.newFolder();
@@ -153,7 +151,6 @@ public void sendFileIsThrottled() throws Exception {
153151

154152
@Test
155153
public void dataUploadIsThrottled() {
156-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
157154
long startTime = System.nanoTime();
158155

159156
Buffer expected = TestUtils.randomBuffer(64 * 1024 * 4);
@@ -185,7 +182,6 @@ public void dataUploadIsThrottled() {
185182

186183
@Test
187184
public void fileUploadIsThrottled() throws Exception {
188-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
189185
long startTime = System.nanoTime();
190186

191187
File fDir = testFolder.newFolder();
@@ -220,7 +216,6 @@ public void fileUploadIsThrottled() throws Exception {
220216

221217
@Test
222218
public void testSendBufferIsTrafficShapedWithSharedServers() throws Exception {
223-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
224219
Buffer expected = TestUtils.randomBuffer(64 * 1024 * 4);
225220

226221
int numEventLoops = 4; // We start a shared TCP server with 4 event-loops
@@ -264,8 +259,6 @@ public void start(Promise<Void> startPromise) {
264259

265260
@Test
266261
public void testDynamicInboundRateUpdate() {
267-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
268-
269262
Buffer expected = TestUtils.randomBuffer(64 * 1024 * 4);
270263
NetServer server = netServer();
271264

@@ -299,7 +292,6 @@ public void testDynamicInboundRateUpdate() {
299292

300293
@Test
301294
public void testDynamicOutboundRateUpdate() {
302-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
303295
long startTime = System.nanoTime();
304296

305297
Buffer expected = TestUtils.randomBuffer(64 * 1024 * 4);
@@ -338,7 +330,6 @@ public void testDynamicOutboundRateUpdate() {
338330

339331
@Test(expected = IllegalStateException.class)
340332
public void testRateUpdateWhenServerStartedWithoutTrafficShaping() throws Exception {
341-
Assume.assumeFalse(TRANSPORT == Transport.IO_URING);
342333
NetServerOptions options = new NetServerOptions().setHost(DEFAULT_HOST).setPort(DEFAULT_PORT);
343334
NetServer testServer = netServer(options);
344335

0 commit comments

Comments
 (0)