The code we have will try for epoll and then fall back to nio if it does not
work.
There are a few places in the code that we do this, but they all more or less
boil down to something like the following
static EventLoopGroup getDefaultEventLoopGroup() {
ThreadFactory threadFactory = new DefaultThreadFactory("bookkeeper-io");
final int numThreads = Runtime.getRuntime().availableProcessors() * 2;
if (SystemUtils.IS_OS_LINUX) {
try {
return new EpollEventLoopGroup(numThreads, threadFactory);
} catch (Throwable t) {
if (LOG.isDebugEnabled()) {
LOG.debug("Could not use Netty Epoll event loop: {}",
t.getMessage());
}
return new NioEventLoopGroup(numThreads, threadFactory);
}
} else {
return new NioEventLoopGroup(numThreads, threadFactory);
}
}
...
if (eventLoopGroup instanceof EpollEventLoopGroup) {
bootstrap.channel(EpollServerSocketChannel.class);
} else {
bootstrap.channel(NioServerSocketChannel.class);
}
- Bobby
On Saturday, March 4, 2017, 8:29:52 AM CST, Enrico Olivelli
<[email protected]> wrote:Hi all,
As we are switching to netty 4.1 maybe ee can look to this too:
http://netty.io/wiki/native-transports.html
Even if I have been using netty 4 for some year I did not get this
promising feature on linux.
Did any of you ever give it a try?
Enrico
--
-- Enrico Olivelli