Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
"dev.cel:common:0.12.0",
"com.squareup.okhttp:okhttp:2.7.5",
"com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day
"io.netty:netty-buffer:4.1.135.Final",
"io.netty:netty-codec-http2:4.1.135.Final",
"io.netty:netty-codec-http:4.1.135.Final",
"io.netty:netty-codec-socks:4.1.135.Final",
"io.netty:netty-codec:4.1.135.Final",
"io.netty:netty-common:4.1.135.Final",
"io.netty:netty-handler-proxy:4.1.135.Final",
"io.netty:netty-handler:4.1.135.Final",
"io.netty:netty-resolver:4.1.135.Final",
"io.netty:netty-buffer:4.2.15.Final",
"io.netty:netty-codec-base:4.2.15.Final",
"io.netty:netty-codec-http2:4.2.15.Final",
"io.netty:netty-codec-http:4.2.15.Final",
"io.netty:netty-codec-socks:4.2.15.Final",
"io.netty:netty-common:4.2.15.Final",
"io.netty:netty-handler-proxy:4.2.15.Final",
"io.netty:netty-handler:4.2.15.Final",
"io.netty:netty-resolver:4.2.15.Final",
"io.netty:netty-tcnative-boringssl-static:2.0.75.Final",
"io.netty:netty-tcnative-classes:2.0.75.Final",
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.135.Final",
"io.netty:netty-transport-native-unix-common:4.1.135.Final",
"io.netty:netty-transport:4.1.135.Final",
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.2.15.Final",
"io.netty:netty-transport-native-unix-common:4.2.15.Final",
"io.netty:netty-transport:4.2.15.Final",
"io.opencensus:opencensus-api:0.31.0",
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
"io.perfmark:perfmark-api:0.27.0",
Expand Down
2 changes: 1 addition & 1 deletion alts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ java_library(
artifact("com.google.errorprone:error_prone_annotations"),
artifact("com.google.guava:guava"),
artifact("io.netty:netty-buffer"),
artifact("io.netty:netty-codec"),
artifact("io.netty:netty-codec-base"),
artifact("io.netty:netty-common"),
artifact("io.netty:netty-handler"),
artifact("io.netty:netty-transport"),
Expand Down
5 changes: 3 additions & 2 deletions alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.grpc.internal.SharedResourceHolder.Resource;
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -78,8 +77,10 @@ public ChannelResource(String target) {
@Override
public Channel create() {
/* Use its own event loop thread pool to avoid blocking. */
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup eventGroup =
new NioEventLoopGroup(1, new DefaultThreadFactory("handshaker pool", true));
new io.netty.channel.nio.NioEventLoopGroup(
1, new DefaultThreadFactory("handshaker pool", true));
NettyChannelBuilder channelBuilder =
NettyChannelBuilder.forTarget(target)
.channelType(NioSocketChannel.class, InetSocketAddress.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.grpc.okhttp.OkHttpChannelBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.Channel;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.local.LocalAddress;
Expand Down Expand Up @@ -103,7 +102,8 @@ public void setUp() throws Exception {
case NETTY_LOCAL: {
String name = "bench" + Math.random();
LocalAddress address = new LocalAddress(name);
EventLoopGroup group = new DefaultEventLoopGroup();
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup group = new io.netty.channel.DefaultEventLoopGroup();
serverBuilder = NettyServerBuilder.forAddress(address, serverCreds)
.bossEventLoopGroup(group)
.workerEventLoopGroup(group)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
Expand Down Expand Up @@ -229,8 +228,14 @@ public void setup(ExecutorType clientExecutor,

// Always use a different worker group from the client.
ThreadFactory serverThreadFactory = new DefaultThreadFactory("STF pool", true /* daemon */);
serverBuilder.workerEventLoopGroup(new NioEventLoopGroup(0, serverThreadFactory));
serverBuilder.bossEventLoopGroup(new NioEventLoopGroup(1, serverThreadFactory));
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup workerGroup =
new io.netty.channel.nio.NioEventLoopGroup(0, serverThreadFactory);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup bossGroup =
new io.netty.channel.nio.NioEventLoopGroup(1, serverThreadFactory);
serverBuilder.workerEventLoopGroup(workerGroup);
serverBuilder.bossEventLoopGroup(bossGroup);

// Always set connection and stream window size to same value
serverBuilder.flowControlWindow(windowSize.bytes());
Expand Down Expand Up @@ -388,8 +393,11 @@ public void onReady() {
ThreadFactory clientThreadFactory = new DefaultThreadFactory("CTF pool", true /* daemon */);
for (int i = 0; i < channelCount; i++) {
// Use a dedicated event-loop for each channel
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup elg =
new io.netty.channel.nio.NioEventLoopGroup(1, clientThreadFactory);
channels[i] = channelBuilder
.eventLoopGroup(new NioEventLoopGroup(1, clientThreadFactory))
.eventLoopGroup(elg)
.build();
}
}
Expand Down
16 changes: 11 additions & 5 deletions benchmarks/src/main/java/io/grpc/benchmarks/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import io.grpc.okhttp.OkHttpChannelBuilder;
import io.grpc.testing.TlsTesting;
import io.netty.channel.epoll.EpollDomainSocketChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.util.concurrent.DefaultThreadFactory;
Expand Down Expand Up @@ -128,22 +126,30 @@ private static NettyChannelBuilder configureNetty(
DefaultThreadFactory tf = new DefaultThreadFactory("client-elg-", true /*daemon */);
switch (transport) {
case NETTY_NIO:
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup elg = new io.netty.channel.nio.NioEventLoopGroup(0, tf);
builder
.eventLoopGroup(new NioEventLoopGroup(0, tf))
.eventLoopGroup(elg)
.channelType(NioSocketChannel.class, InetSocketAddress.class);
break;

case NETTY_EPOLL:
// These classes only work on Linux.
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup epollElg =
new io.netty.channel.epoll.EpollEventLoopGroup(0, tf);
builder
.eventLoopGroup(new EpollEventLoopGroup(0, tf))
.eventLoopGroup(epollElg)
.channelType(EpollSocketChannel.class, InetSocketAddress.class);
break;

case NETTY_UNIX_DOMAIN_SOCKET:
// These classes only work on Linux.
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup unixElg =
new io.netty.channel.epoll.EpollEventLoopGroup(0, tf);
builder
.eventLoopGroup(new EpollEventLoopGroup(0, tf))
.eventLoopGroup(unixElg)
.channelType(EpollDomainSocketChannel.class, DomainSocketAddress.class);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.grpc.benchmarks.proto.WorkerServiceGrpc;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -45,11 +44,13 @@ public class LoadWorker {

LoadWorker(int driverPort, int serverPort) throws Exception {
this.serverPort = serverPort;
NioEventLoopGroup singleThreadGroup = new NioEventLoopGroup(1,
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("load-worker-%d")
.build());
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup singleThreadGroup =
new io.netty.channel.nio.NioEventLoopGroup(1,
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("load-worker-%d")
.build());
this.driverServer = NettyServerBuilder.forPort(driverPort, InsecureServerCredentials.create())
.directExecutor()
.channelType(NioServerSocketChannel.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.grpc.testing.TlsTesting;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.io.IOException;
Expand Down Expand Up @@ -94,8 +93,12 @@ static Server newServer(ServerConfiguration config) throws IOException {
ThreadFactory tf = new DefaultThreadFactory("server-elg-", true /*daemon */);
switch (config.transport) {
case NETTY_NIO: {
boss = new NioEventLoopGroup(1, tf);
worker = new NioEventLoopGroup(0, tf);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup nioBoss = new io.netty.channel.nio.NioEventLoopGroup(1, tf);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup nioWorker = new io.netty.channel.nio.NioEventLoopGroup(0, tf);
boss = nioBoss;
worker = nioWorker;
channelType = NioServerSocketChannel.class;
break;
}
Expand Down
13 changes: 4 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,14 @@ lincheck = "org.jetbrains.lincheck:lincheck:3.4"
mockito-android = "org.mockito:mockito-android:4.4.0"
# checkForUpdates: mockito-core:4.4.+
mockito-core = "org.mockito:mockito-core:4.4.0"
# Need to decide when we require users to absorb the breaking changes in 4.2
# checkForUpdates: netty-codec-http2:4.1.+
netty-codec-http2 = "io.netty:netty-codec-http2:4.1.135.Final"
# checkForUpdates: netty-handler-proxy:4.1.+
netty-handler-proxy = "io.netty:netty-handler-proxy:4.1.135.Final"
netty-codec-http2 = "io.netty:netty-codec-http2:4.2.15.Final"
netty-handler-proxy = "io.netty:netty-handler-proxy:4.2.15.Final"
# Keep the following references of tcnative version in sync whenever it's updated:
# SECURITY.md
netty-tcnative = "io.netty:netty-tcnative-boringssl-static:2.0.75.Final"
netty-tcnative-classes = "io.netty:netty-tcnative-classes:2.0.75.Final"
# checkForUpdates: netty-transport-epoll:4.1.+
netty-transport-epoll = "io.netty:netty-transport-native-epoll:4.1.135.Final"
# checkForUpdates: netty-unix-common:4.1.+
netty-unix-common = "io.netty:netty-transport-native-unix-common:4.1.135.Final"
netty-transport-epoll = "io.netty:netty-transport-native-epoll:4.2.15.Final"
netty-unix-common = "io.netty:netty-transport-native-unix-common:4.2.15.Final"
okhttp = "com.squareup.okhttp:okhttp:2.7.5"
# okio 3.5+ uses Kotlin 1.9+ which requires Android Gradle Plugin 9+
# checkForUpdates: okio:3.4.+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import io.grpc.testing.integration.Messages.Payload;
import io.grpc.testing.integration.Messages.SimpleRequest;
import io.grpc.testing.integration.Messages.SimpleResponse;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.junit.Before;
Expand Down Expand Up @@ -71,11 +70,15 @@ public void unaryCall(SimpleRequest request, StreamObserver<SimpleResponse> so)
public void setup() throws Exception {
// create new EventLoopGroups to avoid deadlock at server side handshake negotiation, e.g.
// happens when handshakerServer and testServer child channels are on the same eventloop.
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup bossGroup =
new io.netty.channel.nio.NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-boss"));
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
io.netty.channel.EventLoopGroup workerGroup =
new io.netty.channel.nio.NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-worker"));
handshakerServer = grpcCleanup.register(NettyServerBuilder.forPort(0)
.bossEventLoopGroup(
new NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-boss")))
.workerEventLoopGroup(
new NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-worker")))
.bossEventLoopGroup(bossGroup)
.workerEventLoopGroup(workerGroup)
.channelType(NioServerSocketChannel.class)
.addService(new AltsHandshakerTestService())
.build()).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.local.LocalServerChannel;
Expand All @@ -36,7 +36,8 @@
@RunWith(JUnit4.class)
public class Http2NettyLocalChannelTest extends AbstractInteropTest {

private DefaultEventLoopGroup eventLoopGroup = new DefaultEventLoopGroup();
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
private EventLoopGroup eventLoopGroup = new io.netty.channel.DefaultEventLoopGroup();

@Override
protected ServerBuilder<?> getServerBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.testing.GrpcCleanupRule;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
Expand Down Expand Up @@ -111,7 +110,8 @@ public class RetryTest {
mock(ClientCall.Listener.class, delegatesTo(testCallListener));

private CountDownLatch backoffLatch = new CountDownLatch(1);
private final EventLoopGroup clientGroup = new DefaultEventLoopGroup(1) {
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
private final EventLoopGroup clientGroup = new io.netty.channel.DefaultEventLoopGroup(1) {
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public ScheduledFuture<?> schedule(
Expand All @@ -138,7 +138,8 @@ public void run() {} // no-op
TimeUnit.NANOSECONDS);
}
};
private final EventLoopGroup serverGroup = new DefaultEventLoopGroup(1);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
private final EventLoopGroup serverGroup = new io.netty.channel.DefaultEventLoopGroup(1);
private final FakeStatsRecorder clientStatsRecorder = new FakeStatsRecorder();
private final ClientInterceptor statsInterceptor =
InternalCensusStatsAccessor.getClientInterceptor(
Expand Down
2 changes: 1 addition & 1 deletion netty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ java_library(
artifact("com.google.errorprone:error_prone_annotations"),
artifact("com.google.guava:guava"),
artifact("io.netty:netty-buffer"),
artifact("io.netty:netty-codec"),
artifact("io.netty:netty-codec-base"),
artifact("io.netty:netty-codec-http"),
artifact("io.netty:netty-codec-http2"),
artifact("io.netty:netty-codec-socks"),
Expand Down
6 changes: 4 additions & 2 deletions netty/src/main/java/io/grpc/netty/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ReflectiveChannelFactory;
import io.netty.channel.ServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.DecoderException;
Expand Down Expand Up @@ -513,7 +512,10 @@ public EventLoopGroup create() {
ThreadFactory threadFactory = new DefaultThreadFactory(name, /* daemon= */ true);
switch (eventLoopGroupType) {
case NIO:
return new NioEventLoopGroup(numEventLoops, threadFactory);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup group =
new io.netty.channel.nio.NioEventLoopGroup(numEventLoops, threadFactory);
return group;
case EPOLL:
return createEpollEventLoopGroup(numEventLoops, threadFactory);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ReflectiveChannelFactory;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannelConfig;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
Expand Down Expand Up @@ -163,7 +161,8 @@ public class NettyClientTransportTest {
private final List<NettyClientTransport> transports = new ArrayList<>();
private final LinkedBlockingQueue<Attributes> serverTransportAttributesList =
new LinkedBlockingQueue<>();
private final NioEventLoopGroup group = new NioEventLoopGroup(1);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
private final EventLoopGroup group = new io.netty.channel.nio.NioEventLoopGroup(1);
private final EchoServerListener serverListener = new EchoServerListener();
private final InternalChannelz channelz = new InternalChannelz();
private Runnable tooManyPingsRunnable = new Runnable() {
Expand Down Expand Up @@ -591,7 +590,8 @@ public void channelFactoryShouldSetSocketOptionKeepAlive() throws Exception {
@Test
public void channelFactoryShouldNNotSetSocketOptionKeepAlive() throws Exception {
startServer();
DefaultEventLoopGroup group = new DefaultEventLoopGroup(1);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
EventLoopGroup group = new io.netty.channel.DefaultEventLoopGroup(1);
try {
NettyClientTransport transport = newTransport(newNegotiator(),
DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true,
Expand Down
4 changes: 2 additions & 2 deletions netty/src/test/java/io/grpc/netty/NettyServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ReflectiveChannelFactory;
import io.netty.channel.WriteBufferWaterMark;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.AsciiString;
import io.netty.util.concurrent.Future;
Expand Down Expand Up @@ -88,7 +87,8 @@ public class NettyServerTest {
@Rule public final MockitoRule mocks = MockitoJUnit.rule();

private final InternalChannelz channelz = new InternalChannelz();
private final NioEventLoopGroup eventLoop = new NioEventLoopGroup(1);
@SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API
private final EventLoopGroup eventLoop = new io.netty.channel.nio.NioEventLoopGroup(1);
private final ChannelFactory<NioServerSocketChannel> channelFactory =
new ReflectiveChannelFactory<>(NioServerSocketChannel.class);

Expand Down
Loading
Loading