Author: kfujino Date: Fri Apr 21 06:28:26 2017 New Revision: 1792167 URL: http://svn.apache.org/viewvc?rev=1792167&view=rev Log: Add features to get the statistics of the thread pool of the MessageDispatchInterceptor. These statistics information can be acquired via JMX.
Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java?rev=1792167&r1=1792166&r2=1792167&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java Fri Apr 21 06:28:26 2017 @@ -17,6 +17,7 @@ package org.apache.catalina.tribes.group.interceptors; import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -278,4 +279,54 @@ public class MessageDispatchInterceptor addAndGetCurrentSize(-msg.getMessage().getLength()); } } + + // ---------------------------------------------- stats of the thread pool + /** + * Return the current number of threads that are managed by the pool. + * @return the current number of threads that are managed by the pool + */ + public int getPoolSize() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getPoolSize(); + } else { + return -1; + } + } + + /** + * Return the current number of threads that are in use. + * @return the current number of threads that are in use + */ + public int getActiveCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getActiveCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have ever been scheduled for execution by the pool. + * @return the total number of tasks that have ever been scheduled for execution by the pool + */ + public long getTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getTaskCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have completed execution by the pool. + * @return the total number of tasks that have completed execution by the pool + */ + public long getCompletedTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getCompletedTaskCount(); + } else { + return -1; + } + } + } Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java?rev=1792167&r1=1792166&r2=1792167&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java Fri Apr 21 06:28:26 2017 @@ -34,4 +34,13 @@ public interface MessageDispatchIntercep public int getMaxThreads(); + // pool stats + public int getPoolSize(); + + public int getActiveCount(); + + public long getTaskCount(); + + public long getCompletedTaskCount(); + } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1792167&r1=1792166&r2=1792167&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Apr 21 06:28:26 2017 @@ -75,8 +75,9 @@ <changelog> <add> Add features to get the statistics of the thread pool of the - <code>Receiver</code> component. These statistics information can be - acquired via JMX. (kfujino) + <code>Receiver</code> component and + <code>MessageDispatchInterceptor</code>. These statistics information + can be acquired via JMX. (kfujino) </add> <add> Add <code>maxIdleTime</code> attribute to <code>NioReceiverMBean</code> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org