You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:25:42 UTC
[sling-org-apache-sling-commons-threads] 03/09: SLING-1820 :
Display current pool statistics in web console
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 540bc621fd98af244d38dbcf10a67169ff24308e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 6 14:07:45 2010 +0000
SLING-1820 : Display current pool statistics in web console
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1005046 13f79535-47bb-0310-9956-ffa450edef68
---
.../commons/threads/impl/DefaultThreadPool.java | 4 +++
.../threads/impl/DefaultThreadPoolManager.java | 8 +++++
.../commons/threads/impl/ThreadPoolFacade.java | 6 ++++
.../commons/threads/impl/WebConsolePrinter.java | 38 +++++++++++++++++-----
4 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
index 2a97469..dee1524 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
@@ -199,4 +199,8 @@ public class DefaultThreadPool
}
this.logger.info("Thread pool [{}] is shut down.", this.name);
}
+
+ public ThreadPoolExecutor getExecutor() {
+ return this.executor;
+ }
}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
index b99c653..0d70f61 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -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;
+ }
}
}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java b/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
index 145c9c8..0135e3c 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolFacade.java
@@ -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 implements ThreadPool {
this.delegatee = pool;
oldPool.shutdown();
}
+
+ public ThreadPoolExecutor getExecutor() {
+ return this.delegatee.getExecutor();
+ }
}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java b/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
index b0aedf0..9adc5e5 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/WebConsolePrinter.java
@@ -21,8 +21,10 @@ package org.apache.sling.commons.threads.impl;
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 implements ConfigurationPrinter {
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 implements ConfigurationPrinter {
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 {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.