Merge pull request #27 from normanmaurer/close_group
Call IOUringEventLoopGroup.shutdownGracefully() after test is done.
This commit is contained in:
commit
a55313ed75
@ -8,6 +8,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
|
|||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
import io.netty.channel.socket.ServerSocketChannel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.logging.LogLevel;
|
import io.netty.handler.logging.LogLevel;
|
||||||
import io.netty.handler.logging.LoggingHandler;
|
import io.netty.handler.logging.LoggingHandler;
|
||||||
@ -24,7 +25,7 @@ public class PollRemoveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Sharable
|
@Sharable
|
||||||
class EchoUringServerHandler extends ChannelInboundHandlerAdapter {
|
private static final class EchoUringServerHandler extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||||
@ -46,29 +47,33 @@ public class PollRemoveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void io_uring_test() throws Exception {
|
void io_uring_test() throws Exception {
|
||||||
Class clazz;
|
Class<? extends ServerSocketChannel> clazz = IOUringServerSocketChannel.class;
|
||||||
final EventLoopGroup bossGroup = new IOUringEventLoopGroup(1);
|
final EventLoopGroup bossGroup = new IOUringEventLoopGroup(1);
|
||||||
final EventLoopGroup workerGroup = new IOUringEventLoopGroup(1);
|
final EventLoopGroup workerGroup = new IOUringEventLoopGroup(1);
|
||||||
clazz = IOUringServerSocketChannel.class;
|
|
||||||
|
|
||||||
ServerBootstrap b = new ServerBootstrap();
|
try {
|
||||||
b.group(bossGroup, workerGroup)
|
ServerBootstrap b = new ServerBootstrap();
|
||||||
.channel(clazz)
|
b.group(bossGroup, workerGroup)
|
||||||
.handler(new LoggingHandler(LogLevel.TRACE))
|
.channel(clazz)
|
||||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
.handler(new LoggingHandler(LogLevel.TRACE))
|
||||||
@Override
|
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||||
public void initChannel(SocketChannel ch) throws Exception {
|
@Override
|
||||||
ChannelPipeline p = ch.pipeline();
|
public void initChannel(SocketChannel ch) throws Exception {
|
||||||
|
ChannelPipeline p = ch.pipeline();
|
||||||
|
|
||||||
p.addLast(new EchoUringServerHandler());
|
p.addLast(new EchoUringServerHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Channel sc = b.bind(2020).sync().channel();
|
Channel sc = b.bind(2020).sync().channel();
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
|
|
||||||
//close ServerChannel
|
// close ServerChannel
|
||||||
sc.close().sync();
|
sc.close().sync();
|
||||||
|
} finally {
|
||||||
|
bossGroup.shutdownGracefully();
|
||||||
|
workerGroup.shutdownGracefully();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user