Reputation: 95
I have a server built with Netty and its threadpool is based on bossGroup/workerGroup model. Which is the basic Netty server implementation:
EventLoopGroup bossGroup = new NioEventLoopGroup(poolSize);
EventLoopGroup workerGroup = new NioEventLoopGroup(poolSize);
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new TelnetServerInitializer());
b.bind(PORT);
If I would like to monitor activity of the two threadpool bossGroup and workerPool, something like the active thread counts and pool size? How should I do?
For Java's ThreadPoolExecutor, I have the:
ThreadPoolExecutor.getActiveCount()
ThreadPoolExecutor.getQueue.size()
For EventLoopGroup, it also extends ExecutorService. Is there a way to get those information?
Upvotes: 3
Views: 2778
Reputation: 23557
If you use NioEventLoopGroup
/ EpollEventLoopGroup
/ KQueueEventLoopGroup
you can use SingleThreadEventExecutor.pendingTasks()
:
You can obtain all the executors via:
EventLoopGroup.iterator()
Upvotes: 3