Make several low-level netty parameters configurable
This commit is contained in:
@@ -51,4 +51,8 @@ public class BrokerConstants {
|
|||||||
public static final String HOST = "0.0.0.0";
|
public static final String HOST = "0.0.0.0";
|
||||||
public static final String NEED_CLIENT_AUTH = "need_client_auth";
|
public static final String NEED_CLIENT_AUTH = "need_client_auth";
|
||||||
public static final String HAZELCAST_CONFIGURATION = "hazelcast.configuration";
|
public static final String HAZELCAST_CONFIGURATION = "hazelcast.configuration";
|
||||||
|
public static final String NETTY_SO_BACKLOG = "netty.so_backlog";
|
||||||
|
public static final String NETTY_SO_REUSEADDR = "netty.so_reuseaddr";
|
||||||
|
public static final String NETTY_TCP_NODELAY = "netty.tcp_nodelay";
|
||||||
|
public static final String NETTY_SO_KEEPALIVE = "netty.so_keepalive";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,21 @@ public class NettyAcceptor implements ServerAcceptor {
|
|||||||
BytesMetricsCollector m_bytesMetricsCollector = new BytesMetricsCollector();
|
BytesMetricsCollector m_bytesMetricsCollector = new BytesMetricsCollector();
|
||||||
MessageMetricsCollector m_metricsCollector = new MessageMetricsCollector();
|
MessageMetricsCollector m_metricsCollector = new MessageMetricsCollector();
|
||||||
|
|
||||||
|
private int nettySoBacklog;
|
||||||
|
private boolean nettySoReuseaddr;
|
||||||
|
private boolean nettyTcpNodelay;
|
||||||
|
private boolean nettySoKeepalive;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ProtocolProcessor processor, IConfig props, ISslContextCreator sslCtxCreator) throws IOException {
|
public void initialize(ProtocolProcessor processor, IConfig props, ISslContextCreator sslCtxCreator) throws IOException {
|
||||||
LOG.info("Initializing Netty acceptor...");
|
LOG.info("Initializing Netty acceptor...");
|
||||||
m_bossGroup = new NioEventLoopGroup();
|
|
||||||
|
nettySoBacklog = Integer.parseInt(props.getProperty(BrokerConstants.NETTY_SO_BACKLOG, "128"));
|
||||||
|
nettySoReuseaddr = Boolean.parseBoolean(props.getProperty(BrokerConstants.NETTY_SO_REUSEADDR, "true"));
|
||||||
|
nettyTcpNodelay = Boolean.parseBoolean(props.getProperty(BrokerConstants.NETTY_TCP_NODELAY, "true"));
|
||||||
|
nettySoKeepalive = Boolean.parseBoolean(props.getProperty(BrokerConstants.NETTY_SO_KEEPALIVE, "true"));
|
||||||
|
|
||||||
|
m_bossGroup = new NioEventLoopGroup();
|
||||||
m_workerGroup = new NioEventLoopGroup();
|
m_workerGroup = new NioEventLoopGroup();
|
||||||
final NettyMQTTHandler handler = new NettyMQTTHandler(processor);
|
final NettyMQTTHandler handler = new NettyMQTTHandler(processor);
|
||||||
|
|
||||||
@@ -134,10 +145,10 @@ public class NettyAcceptor implements ServerAcceptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.option(ChannelOption.SO_BACKLOG, 128)
|
.option(ChannelOption.SO_BACKLOG, nettySoBacklog)
|
||||||
.option(ChannelOption.SO_REUSEADDR, true)
|
.option(ChannelOption.SO_REUSEADDR, nettySoReuseaddr)
|
||||||
.option(ChannelOption.TCP_NODELAY, true)
|
.option(ChannelOption.TCP_NODELAY, nettyTcpNodelay)
|
||||||
.childOption(ChannelOption.SO_KEEPALIVE, true);
|
.childOption(ChannelOption.SO_KEEPALIVE, nettySoKeepalive);
|
||||||
try {
|
try {
|
||||||
LOG.info("Binding server. Protocol = {}, host = {}, port = {}.", host, port);
|
LOG.info("Binding server. Protocol = {}, host = {}, port = {}.", host, port);
|
||||||
// Bind and start to accept incoming connections.
|
// Bind and start to accept incoming connections.
|
||||||
|
|||||||
Reference in New Issue
Block a user