如何监控Netty EventLoopGroup线程池

3

我有一个使用Netty构建的服务器,其线程池基于bossGroup/workerGroup模型。这是基本的Netty服务器实现:

    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);

如果我想监控两个线程池 bossGroup 和 workerPool 的活动情况,例如活动线程数和池大小,应该如何做?

对于 Java 的 ThreadPoolExecutor,我有以下选项:

ThreadPoolExecutor.getActiveCount()
ThreadPoolExecutor.getQueue.size() 

对于EventLoopGroup来说,它也扩展了ExecutorService。有没有一种方法可以获得这些信息?
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接