Example usage for io.netty.channel SingleThreadEventLoop threadProperties

List of usage examples for io.netty.channel SingleThreadEventLoop threadProperties

Introduction

In this page you can find the example usage for io.netty.channel SingleThreadEventLoop threadProperties.

Prototype

public final ThreadProperties threadProperties() 

Source Link

Document

Returns the ThreadProperties of the Thread that powers the SingleThreadEventExecutor .

Usage

From source file:com.mpush.tools.thread.pool.ThreadPoolManager.java

License:Apache License

public static Map<String, Object> getPoolInfo(EventLoopGroup executors) {
    Map<String, Object> info = new HashMap<>(3);
    int poolSize = 0, queueSize = 0, activeCount = 0;
    for (EventExecutor e : executors) {
        poolSize++;//from   w  ww .  j  a  v a2 s  .  com
        if (e instanceof SingleThreadEventLoop) {
            SingleThreadEventLoop executor = (SingleThreadEventLoop) e;
            queueSize += executor.pendingTasks();
            ThreadProperties tp = executor.threadProperties();
            if (tp.state() == Thread.State.RUNNABLE) {
                activeCount++;
            }
        }
    }
    info.put("poolSize(workThread)", poolSize);
    info.put("activeCount(workingThread)", activeCount);
    info.put("queueSize(blockedTask)", queueSize);
    return info;
}