use of org.apache.flink.shaded.netty4.io.netty.channel.epoll.EpollEventLoopGroup in project ambry by linkedin.
the class NettyServer method start.
@Override
public void start() throws InstantiationException {
long startupBeginTime = System.currentTimeMillis();
try {
logger.trace("Starting NettyServer deployment");
if (Epoll.isAvailable()) {
logger.trace("Using EpollEventLoopGroup in NettyServer.");
bossGroup = new EpollEventLoopGroup(nettyConfig.nettyServerBossThreadCount);
workerGroup = new EpollEventLoopGroup(nettyConfig.nettyServerWorkerThreadCount);
} else {
bossGroup = new NioEventLoopGroup(nettyConfig.nettyServerBossThreadCount);
workerGroup = new NioEventLoopGroup(nettyConfig.nettyServerWorkerThreadCount);
}
for (Map.Entry<Integer, ChannelInitializer<SocketChannel>> entry : channelInitializers.entrySet()) {
bindServer(entry.getKey(), entry.getValue(), bossGroup, workerGroup);
}
nettyMetrics.registerNettyPendingTasksGauge(bossGroup, "Boss");
nettyMetrics.registerNettyPendingTasksGauge(workerGroup, "Worker");
} catch (InterruptedException e) {
logger.error("NettyServer start await was interrupted", e);
nettyMetrics.nettyServerStartError.inc();
throw new InstantiationException("Netty server bind to port [" + nettyConfig.nettyServerPort + "] was interrupted");
} finally {
long startupTime = System.currentTimeMillis() - startupBeginTime;
logger.info("NettyServer start took {} ms", startupTime);
nettyMetrics.nettyServerStartTimeInMs.update(startupTime);
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.epoll.EpollEventLoopGroup in project lispflowmapping by opendaylight.
the class LispSouthboundPlugin method init.
public void init() {
LOG.info("LISP (RFC6830) Southbound Plugin is initializing...");
synchronized (startLock) {
this.akdb = new AuthKeyDb(new HashMapDb());
this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, akdb);
this.dsbe = new DataStoreBackEnd(dataBroker);
restoreDaoFromDatastore();
LispSouthboundHandler lsbh = new LispSouthboundHandler(this);
this.lispSouthboundHandler = lsbh;
LispXtrSouthboundHandler lxsbh = new LispXtrSouthboundHandler(this);
this.lispXtrSouthboundHandler = lxsbh;
if (Epoll.isAvailable()) {
eventLoopGroup = new EpollEventLoopGroup(numChannels, threadFactory);
channelType = EpollDatagramChannel.class;
bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
bootstrap.option(EpollChannelOption.SO_REUSEPORT, true);
LOG.debug("Using Netty Epoll for UDP sockets");
} else {
eventLoopGroup = new NioEventLoopGroup(0, threadFactory);
channelType = NioDatagramChannel.class;
LOG.debug("Using Netty I/O (non-Epoll) for UDP sockets");
}
bootstrap.group(eventLoopGroup);
bootstrap.channel(channelType);
bootstrap.handler(lsbh);
xtrBootstrap.group(eventLoopGroup);
xtrBootstrap.channel(channelType);
xtrBootstrap.handler(lxsbh);
start();
startXtr();
clusterSingletonService.registerClusterSingletonService(this);
LOG.info("LISP (RFC6830) Southbound Plugin is up!");
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.epoll.EpollEventLoopGroup in project netty by netty.
the class EpollSocketChannelBenchmark method setup.
@Setup
public void setup() throws Exception {
group = new EpollEventLoopGroup(1);
// add an arbitrary timeout to make the timer reschedule
future = group.schedule(new Runnable() {
@Override
public void run() {
throw new AssertionError();
}
}, 5, TimeUnit.MINUTES);
serverChan = new ServerBootstrap().channel(EpollServerSocketChannel.class).group(group).childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(new ChannelDuplexHandler() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof ByteBuf) {
ctx.writeAndFlush(msg, ctx.voidPromise());
} else {
throw new AssertionError();
}
}
});
}
}).bind(0).sync().channel();
chan = new Bootstrap().channel(EpollSocketChannel.class).handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(new ChannelDuplexHandler() {
private ChannelPromise lastWritePromise;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof ByteBuf) {
ByteBuf buf = (ByteBuf) msg;
try {
if (buf.readableBytes() == 1) {
lastWritePromise.trySuccess();
lastWritePromise = null;
} else {
throw new AssertionError();
}
} finally {
buf.release();
}
} else {
throw new AssertionError();
}
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (lastWritePromise != null) {
throw new IllegalStateException();
}
lastWritePromise = promise;
super.write(ctx, msg, ctx.voidPromise());
}
});
}
}).group(group).connect(serverChan.localAddress()).sync().channel();
abyte = chan.alloc().directBuffer(1);
abyte.writeByte('a');
}
use of org.apache.flink.shaded.netty4.io.netty.channel.epoll.EpollEventLoopGroup in project flink by apache.
the class NettyServer method initEpollBootstrap.
private void initEpollBootstrap() {
// Add the server port number to the name in order to distinguish
// multiple servers running on the same host.
String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";
EpollEventLoopGroup epollGroup = new EpollEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name));
bootstrap.group(epollGroup).channel(EpollServerSocketChannel.class);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.epoll.EpollEventLoopGroup in project blade by biezhi.
the class EpollKit method group.
static NettyServerGroup group(int threadCount, int workers) {
var bossGroup = new EpollEventLoopGroup(threadCount, new NamedThreadFactory("epoll-boss@"));
var workerGroup = new EpollEventLoopGroup(workers, new NamedThreadFactory("epoll-worker@"));
return NettyServerGroup.builder().boosGroup(bossGroup).workerGroup(workerGroup).socketChannel(EpollServerSocketChannel.class).build();
}
Aggregations