Added extra params in config for Netty

This commit is contained in:
Nanit 2020-11-29 15:10:33 +02:00
parent 7ba831d1a6
commit 8404135e42
3 changed files with 35 additions and 6 deletions

View File

@ -30,6 +30,10 @@ public final class LimboConfig {
private long readTimeout; private long readTimeout;
private int debugLevel = 3; private int debugLevel = 3;
private boolean useEpoll;
private int bossGroupSize;
private int workerGroupSize;
public LimboConfig(Path root){ public LimboConfig(Path root){
this.root = root; this.root = root;
} }
@ -59,6 +63,10 @@ public final class LimboConfig {
infoForwarding = conf.getNode("infoForwarding").getValue(InfoForwarding.class); infoForwarding = conf.getNode("infoForwarding").getValue(InfoForwarding.class);
readTimeout = conf.getNode("readTimeout").getLong(); readTimeout = conf.getNode("readTimeout").getLong();
debugLevel = conf.getNode("debugLevel").getInt(); debugLevel = conf.getNode("debugLevel").getInt();
useEpoll = conf.getNode("netty", "useEpoll").getBoolean(true);
bossGroupSize = conf.getNode("netty", "threads", "bossGroup").getInt(1);
workerGroupSize = conf.getNode("netty", "threads", "workerGroup").getInt(4);
} }
public SocketAddress getAddress() { public SocketAddress getAddress() {
@ -112,4 +120,16 @@ public final class LimboConfig {
public BossBar getBossBar() { public BossBar getBossBar() {
return bossBar; return bossBar;
} }
public boolean isUseEpoll() {
return useEpoll;
}
public int getBossGroupSize() {
return bossGroupSize;
}
public int getWorkerGroupSize() {
return workerGroupSize;
}
} }

View File

@ -80,14 +80,14 @@ public final class LimboServer {
private void startBootstrap(){ private void startBootstrap(){
Class<? extends ServerChannel> channelClass; Class<? extends ServerChannel> channelClass;
if (Epoll.isAvailable()){ if (config.isUseEpoll() && Epoll.isAvailable()){
bossGroup = new EpollEventLoopGroup(1); bossGroup = new EpollEventLoopGroup(config.getBossGroupSize());
workerGroup = new EpollEventLoopGroup(4); workerGroup = new EpollEventLoopGroup(config.getWorkerGroupSize());
channelClass = EpollServerSocketChannel.class; channelClass = EpollServerSocketChannel.class;
Logger.debug("Using Epoll transport type"); Logger.debug("Using Epoll transport type");
} else { } else {
bossGroup = new NioEventLoopGroup(1); bossGroup = new NioEventLoopGroup(config.getBossGroupSize());
workerGroup = new NioEventLoopGroup(4); workerGroup = new NioEventLoopGroup(config.getWorkerGroupSize());
channelClass = NioServerSocketChannel.class; channelClass = NioServerSocketChannel.class;
Logger.debug("Using Java NIO transport type"); Logger.debug("Using Java NIO transport type");
} }

View File

@ -65,3 +65,12 @@ readTimeout: 30000
# 2 - Display info and warnings # 2 - Display info and warnings
# 3 - Display info, warnings, errors # 3 - Display info, warnings, errors
debugLevel: 3 debugLevel: 3
# Warning! Do not touch params of this block, if you not completely sure what is this!
netty:
# Use Linux native transport type, if it possible
useEpoll: true
# EventLoopGroup threads count
threads:
bossGroup: 1
workerGroup: 4