Repository navigation
Conversation
| */ | ||
| package org.apache.dubbo.remoting.transport.netty4; | ||
|
|
||
| import io.netty.bootstrap.Bootstrap; |
There was a problem hiding this comment.
pls. don't change import order. Refer to https://github.com/apache/dubbo/blob/master/CONTRIBUTING.md#code-style for the details.
| /** | ||
| * the os name | ||
| */ | ||
| private static final String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); |
There was a problem hiding this comment.
use Locale.ENGLISH instead of Locale.UK
| * netty client bootstrap | ||
| */ | ||
| private static final NioEventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)); | ||
| private static final EventLoopGroup eventLoopGroup = "linux".equals(osName) ? new EpollEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)): new NioEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)); |
There was a problem hiding this comment.
pls. pay attention to line wrap, which should be 120 column wide. Is it better to rewrite like this:
private static EventLoopGroup eventLoopGroup() {
String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.ENGLISH).trim();
return "linux".equals(osName) ?
new EpollEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)) :
new NioEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true));
}| final NettyClientHandler nettyClientHandler = new NettyClientHandler(getUrl(), this); | ||
| bootstrap = new Bootstrap(); | ||
| bootstrap.group(nioEventLoopGroup) | ||
| bootstrap.group(eventLoopGroup) |
There was a problem hiding this comment.
if we have two factory methods, then we can change this logic to
bootstrap.group(eventLoopGroup())
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
//.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, getTimeout())
.channel(socketChannelClass());socketChannelClass()
private static Class<? extends SocketChannel> socketChannelClass() {
String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.ENGLISH).trim();
return "linux".equals(osName) ? EpollSocketChannel.class : NioSocketChannel.class)
}| /** | ||
| * the os name | ||
| */ | ||
| private static final String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); |
| */ | ||
| package org.apache.dubbo.remoting.transport.netty4; | ||
|
|
||
| import io.netty.bootstrap.ServerBootstrap; |
| new DefaultThreadFactory("NettyServerWorker", true)); | ||
|
|
||
| Class<? extends ServerChannel> channelServerHandler = null; | ||
| if ("linux".equals(osName)) { |
There was a problem hiding this comment.
pls. consider to introduce factory method too.
beiwei30
left a comment
There was a problem hiding this comment.
@lenovoDTC pls. check my comments.
|
You can replace with In fact, some low version Linux doesn't support epoll. Furthermore, support epoll can be configurable. It is better to set a param in the dubbo url to let dubbo user determine whether to use epoll in Linux. Such as me, I prefer to use NioEventLoop because of its compatibility, maybe there are many bugs. |
|
There were some pull requests suggest that Dubbo support epoll, you can reference them |
Moriadry-zz
left a comment
There was a problem hiding this comment.
It doesn't means all linux system can support epoll transport. Maybe io.netty.channel.epoll.isAvailable() is a good choice. Also, we has discussed the performance of epoll before, but no explicit conclusion was found. pls check #4012
|
why close this pull request? let's keep it open. |
|
since there's conflict and the original author fails to respond to the code review, I propose a new pull request #5680 to address this. |
What is the purpose of the change
netty4 support epoll for nio in linux os
Brief changelog
dubbo-remoting/dubbo-remoting-netty4:NettyClient
dubbo-remoting/dubbo-remoting-netty4:NettyServer
Verifying this change
Need to be validated under Linux OS
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false&mvn clean test-compile failsafe:integration-testto make sure unit-test and integration-test pass.