Example usage for io.netty.util.concurrent ThreadProperties state

List of usage examples for io.netty.util.concurrent ThreadProperties state

Introduction

In this page you can find the example usage for io.netty.util.concurrent ThreadProperties state.

Prototype

Thread.State state();

Source Link

Usage

From source file:cn.wantedonline.puppy.httpserver.stat.NioWorkerStat.java

License:Apache License

private String workerThreadStat(NioEventLoop worker) {
    StringBuilder tmp = new StringBuilder();
    if (AssertUtil.isNotNull(worker)) {
        ThreadProperties tp = worker.threadProperties();
        tmp.append(String.format(threadinfoFmt, tp.id(), tp.name(), tp.priority(), tp.state().name()));
    }//from  w w  w.ja  v a2s  .  co  m
    return tmp.toString();
}

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++;//  w w  w .  j av  a  2 s. co  m
        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;
}