From: fhanik Date: Wed, 10 Jun 2009 19:40:31 +0000 (+0000) Subject: Revert my previously not so clever implementation. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=13c2eaf581b68132828775bd8c91f14506963e2b;p=tomcat7.0 Revert my previously not so clever implementation. If there is an executor being used, then one shall expect that the executor is reporting the numbers of threads itself, and it should no longer be the responsibility of the connector git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@783468 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 3191ae10e..bfb5c5c14 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -17,12 +17,10 @@ package org.apache.tomcat.util.net; -import java.lang.reflect.Method; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.Executor; -import java.util.concurrent.ThreadPoolExecutor; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -38,7 +36,6 @@ import org.apache.tomcat.jni.SSLContext; import org.apache.tomcat.jni.SSLSocket; import org.apache.tomcat.jni.Socket; import org.apache.tomcat.jni.Status; -import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.res.StringManager; /** @@ -548,22 +545,7 @@ public class AprEndpoint { */ public int getCurrentThreadCount() { if (executor!=null) { - if (executor instanceof ThreadPoolExecutor) { - return ((ThreadPoolExecutor)executor).getPoolSize(); - } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getPoolSize", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getPoolSize",ignore); - return -2; - } - } + return -1; } else { return curThreads; } @@ -576,22 +558,7 @@ public class AprEndpoint { */ public int getCurrentThreadsBusy() { if (executor!=null) { - if (executor instanceof ThreadPoolExecutor) { - return ((ThreadPoolExecutor)executor).getActiveCount(); - } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getActiveCount", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getActiveCount",ignore); - return -2; - } - } + return -1; } else { return workers!=null?curThreads - workers.size():0; } diff --git a/java/org/apache/tomcat/util/net/JIoEndpoint.java b/java/org/apache/tomcat/util/net/JIoEndpoint.java index 349a172e9..e8b5ef447 100644 --- a/java/org/apache/tomcat/util/net/JIoEndpoint.java +++ b/java/org/apache/tomcat/util/net/JIoEndpoint.java @@ -18,13 +18,11 @@ package org.apache.tomcat.util.net; import java.io.IOException; -import java.lang.reflect.Method; import java.net.BindException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.concurrent.Executor; -import java.util.concurrent.ThreadPoolExecutor; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -306,22 +304,7 @@ public class JIoEndpoint { */ public int getCurrentThreadCount() { if (executor!=null) { - if (executor instanceof ThreadPoolExecutor) { - return ((ThreadPoolExecutor)executor).getPoolSize(); - } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getPoolSize", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getPoolSize",ignore); - return -2; - } - } + return -1; } else { return curThreads; } @@ -334,22 +317,7 @@ public class JIoEndpoint { */ public int getCurrentThreadsBusy() { if (executor!=null) { - if (executor instanceof ThreadPoolExecutor) { - return ((ThreadPoolExecutor)executor).getActiveCount(); - } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getActiveCount", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getActiveCount",ignore); - return -2; - } - } + return -1; } else { return workers!=null?curThreads - workers.size():0; } diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 8a5981d19..82f1fb542 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -20,7 +20,6 @@ package org.apache.tomcat.util.net; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.lang.reflect.Method; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; @@ -731,21 +730,10 @@ public class NioEndpoint { if (executor instanceof ThreadPoolExecutor) { return ((ThreadPoolExecutor)executor).getPoolSize(); } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getPoolSize", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getPoolSize",ignore); - return -2; - } + return -1; } } else { - return -1; + return -2; } } @@ -759,21 +747,10 @@ public class NioEndpoint { if (executor instanceof ThreadPoolExecutor) { return ((ThreadPoolExecutor)executor).getActiveCount(); } else { - try { - Method m = IntrospectionUtils.findMethod(executor.getClass(), "getActiveCount", new Class[] {}); - if (m!=null) { - return ((Integer)m.invoke(executor, null)).intValue(); - } else { - return -1; - } - }catch (Exception ignore) { - if (log.isDebugEnabled()) - log.debug("Unable to invoke getActiveCount",ignore); - return -2; - } + return -1; } } else { - return -1; + return -2; } }