Hi,

Currently Tomcat's thread pool implementation, which is under
org.apache.tomcat.util.net.AbstractEndpoint, does not expose task
queue size via JMX, while in
org.apache.catalina.core.StandardThreadExecutor it can be accessed via
JMX.

The background is that I am involved with a project to auto scale web
application and the size of task queue is helpful to make the
decision.

Therefore I propose to expose it via JMX. The implementation could be
adding a simple method to org.apache.tomcat.util.net.AbstractEndpoint:

public int getThreadPoolTaskQueueSize() {
    if (executor!=null) {
        if (executor instanceof ThreadPoolExecutor) {
            return ((ThreadPoolExecutor)executor).getQueue().size();
        } else if (executor instanceof StandardThreadExecutor) {
            return ((StandardThreadExecutor)executor).getQueueSize();
        } else {
            return -1;
        }
    } else {
        return -2;
    }
}

Another issue is that the default implementation of task queue is hard
coded to be infinite, I think it is better to make it configurable,
just like what StandardThreadExecutor does. But I think it worth
discussion in another thread.

Comments welcome.

-- 
Best Regards!
Huxing

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to