Author: kfujino Date: Fri Apr 14 08:17:17 2017 New Revision: 1791325 URL: http://svn.apache.org/viewvc?rev=1791325&view=rev Log: Add features to get the statistics of the thread pool of the Receiver component. These statistics information can be acquired via JMX.
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java?rev=1791325&r1=1791324&r2=1791325&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java Fri Apr 14 08:17:17 2017 @@ -23,6 +23,7 @@ import java.net.InetSocketAddress; import java.net.ServerSocket; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -516,6 +517,55 @@ public abstract class ReceiverBase imple this.channel = channel; } + // ---------------------------------------------- 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; + } + } + // ---------------------------------------------- ThreadFactory Inner Class class TaskThreadFactory implements ThreadFactory { final ThreadGroup group; Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java?rev=1791325&r1=1791324&r2=1791325&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java Fri Apr 14 08:17:17 2017 @@ -64,4 +64,14 @@ public interface NioReceiverMBean { public boolean getUseBufferPool(); public boolean isListening(); + + // 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=1791325&r1=1791324&r2=1791325&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Apr 14 08:17:17 2017 @@ -54,6 +54,15 @@ </fix> </changelog> </subsection> + <subsection name="Tribes"> + <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) + </add> + </changelog> + </subsection> </section> <section name="Tomcat 9.0.0.M20 (markt)" rtext="release in progress"> <subsection name="Catalina"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org