incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1005046 - in /sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl: DefaultThreadPool.java DefaultThreadPoolManager.java ThreadPoolFacade.java WebConsolePrinter.java
Date Wed, 06 Oct 2010 14:07:45 GMT
Author: cziegeler
Date: Wed Oct  6 14:07:45 2010
New Revision: 1005046

URL: http://svn.apache.org/viewvc?rev=1005046&view=rev
Log:
SLING-1820 : Display current pool statistics in web console

Modified:
    sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
    sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
    sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
    sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java

Modified: sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java?rev=1005046&r1=1005045&r2=1005046&view=diff
==============================================================================
--- sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
(original)
+++ sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
Wed Oct  6 14:07:45 2010
@@ -199,4 +199,8 @@ public class DefaultThreadPool
         }
         this.logger.info("Thread pool [{}] is shut down.", this.name);
     }
+
+    public ThreadPoolExecutor getExecutor() {
+        return this.executor;
+    }
 }

Modified: sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java?rev=1005046&r1=1005045&r2=1005046&view=diff
==============================================================================
--- sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
(original)
+++ sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
Wed Oct  6 14:07:45 2010
@@ -20,6 +20,7 @@ import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ThreadPoolExecutor;
 
 import org.apache.sling.commons.threads.ModifiableThreadPoolConfig;
 import org.apache.sling.commons.threads.ThreadPool;
@@ -326,5 +327,12 @@ public class DefaultThreadPoolManager
         public ThreadPoolConfig getConfig() {
             return this.config;
         }
+
+        public ThreadPoolExecutor getExecutor() {
+            if ( this.pool != null ) {
+                return this.pool.getExecutor();
+            }
+            return null;
+        }
     }
 }

Modified: sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java?rev=1005046&r1=1005045&r2=1005046&view=diff
==============================================================================
--- sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
(original)
+++ sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
Wed Oct  6 14:07:45 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.commons.threads.impl;
 
+import java.util.concurrent.ThreadPoolExecutor;
+
 import org.apache.sling.commons.threads.ThreadPool;
 import org.apache.sling.commons.threads.ThreadPoolConfig;
 
@@ -81,4 +83,8 @@ public final class ThreadPoolFacade impl
         this.delegatee = pool;
         oldPool.shutdown();
     }
+
+    public ThreadPoolExecutor getExecutor() {
+        return this.delegatee.getExecutor();
+    }
 }

Modified: sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java?rev=1005046&r1=1005045&r2=1005046&view=diff
==============================================================================
--- sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
(original)
+++ sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
Wed Oct  6 14:07:45 2010
@@ -21,8 +21,10 @@ package org.apache.sling.commons.threads
 import java.io.PrintWriter;
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.concurrent.ThreadPoolExecutor;
 
 import org.apache.felix.webconsole.ConfigurationPrinter;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -80,6 +82,7 @@ public class WebConsolePrinter implement
         final DefaultThreadPoolManager.Entry[] configs = this.mgr.getConfigurations();
         if ( configs.length > 0 ) {
             for(final DefaultThreadPoolManager.Entry entry : configs ) {
+                final ThreadPoolConfig config = entry.getConfig();
                 pw.print("Pool ");
                 pw.println(entry.getName());
                 if ( entry.getPid() != null ) {
@@ -89,23 +92,40 @@ public class WebConsolePrinter implement
                 pw.print("- used : ");
                 pw.println(entry.isUsed());
                 pw.print("- min pool size : ");
-                pw.println(entry.getConfig().getMinPoolSize());
+                pw.println(config.getMinPoolSize());
                 pw.print("- max pool size : ");
-                pw.println(entry.getConfig().getMaxPoolSize());
+                pw.println(config.getMaxPoolSize());
                 pw.print("- queue size : ");
-                pw.println(entry.getConfig().getQueueSize());
+                pw.println(config.getQueueSize());
                 pw.print("- keep alive time : ");
-                pw.println(entry.getConfig().getKeepAliveTime());
+                pw.println(config.getKeepAliveTime());
                 pw.print("- block policy : ");
-                pw.println(entry.getConfig().getBlockPolicy());
+                pw.println(config.getBlockPolicy());
                 pw.print("- priority : ");
-                pw.println(entry.getConfig().getPriority());
+                pw.println(config.getPriority());
                 pw.print("- shutdown graceful : ");
-                pw.println(entry.getConfig().isShutdownGraceful());
+                pw.println(config.isShutdownGraceful());
                 pw.print("- shutdown wait time : ");
-                pw.println(entry.getConfig().getShutdownWaitTimeMs());
+                pw.println(config.getShutdownWaitTimeMs());
                 pw.print("- daemon : ");
-                pw.println(entry.getConfig().isDaemon());
+                pw.println(config.isDaemon());
+                final ThreadPoolExecutor tpe = entry.getExecutor();
+                if ( tpe != null ) {
+                    pw.print("- active count : ");
+                    pw.println(tpe.getActiveCount());
+                    pw.print("- completed task count : ");
+                    pw.println(tpe.getCompletedTaskCount());
+                    pw.print("- core pool size : ");
+                    pw.println(tpe.getCorePoolSize());
+                    pw.print("- largest pool size : ");
+                    pw.println(tpe.getLargestPoolSize());
+                    pw.print("- maximum pool size : ");
+                    pw.println(tpe.getMaximumPoolSize());
+                    pw.print("- pool size : ");
+                    pw.println(tpe.getPoolSize());
+                    pw.print("- task count : ");
+                    pw.println(tpe.getTaskCount());
+                }
                 pw.println();
             }
         } else {



Mime
View raw message