From 1621bb73ca15b8b6d9fb341d561656d795d675a0 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Fri, 27 Sep 2024 00:11:04 +0200 Subject: [PATCH] Add netty epoll --- .../rockserver/core/server/GrpcServer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java index aaf422b..46f1437 100644 --- a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java +++ b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java @@ -71,13 +71,18 @@ public class GrpcServer extends Server { this.grpc = new GrpcServerImpl(this.getClient()); EventLoopGroup elg; Class channelType; - try { - elg = new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); - channelType = EpollServerDomainSocketChannel.class; - } catch (Throwable ex) { - LOG.warn("Can't load Epoll event loop group, the server will be slower", ex); + if (http2Port != 0) { elg = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); channelType = NioServerSocketChannel.class; + } else { + try { + elg = new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); + channelType = EpollServerDomainSocketChannel.class; + } catch (Throwable ex) { + LOG.warn("Can't load Epoll event loop group, the server will be slower", ex); + elg = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); + channelType = NioServerSocketChannel.class; + } } this.elg = elg; this.executor = Executors.newWorkStealingPool(Runtime.getRuntime().availableProcessors() * 2);