Skip to content

Commit

Permalink
Support netty parameter ChannelOption.SO_BACKLOG configurable (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
galaxylqx authored May 23, 2022
1 parent f9d2f8e commit 7b0c2ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
/**
* Proxy default start port.
*/
PROXY_DEFAULT_PORT("proxy-default-port", "3307", int.class, true);
PROXY_DEFAULT_PORT("proxy-default-port", "3307", int.class, true),

/**
* Proxy Netty backlog size.
*/
PROXY_NETTY_BACKLOG("proxy-netty-backlog", "1024", int.class, false);

private final String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ private EventLoopGroup getWorkerGroup() {
}

private void initServerBootstrap(final ServerBootstrap bootstrap) {
Integer backLog = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_NETTY_BACKLOG);
bootstrap.group(bossGroup, workerGroup)
.channel(Epoll.isAvailable() ? EpollServerSocketChannel.class : NioServerSocketChannel.class)
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024))
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.SO_REUSEADDR, true)
.option(ChannelOption.SO_BACKLOG, backLog)
.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.childOption(ChannelOption.TCP_NODELAY, true)
.handler(new LoggingHandler(LogLevel.INFO))
Expand Down

0 comments on commit 7b0c2ad

Please sign in to comment.