Revert my previously not so clever implementation.
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 10 Jun 2009 19:40:31 +0000 (19:40 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 10 Jun 2009 19:40:31 +0000 (19:40 +0000)
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

java/org/apache/tomcat/util/net/AprEndpoint.java
java/org/apache/tomcat/util/net/JIoEndpoint.java
java/org/apache/tomcat/util/net/NioEndpoint.java

index 3191ae1..bfb5c5c 100644 (file)
 
 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;
         }
index 349a172..e8b5ef4 100644 (file)
 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;
         }
index 8a5981d..82f1fb5 100644 (file)
@@ -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;
         }
     }