Author: remm Date: Thu Mar 22 06:29:30 2007 New Revision: 521257 URL: http://svn.apache.org/viewvc?view=rev&rev=521257 Log: - Expose executors in JMX (shouldn't hurt).
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardService.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardService.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardService.java?view=diff&rev=521257&r1=521256&r2=521257 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardService.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardService.java Thu Mar 22 06:29:30 2007 @@ -518,6 +518,12 @@ } } + synchronized (executors) { + for ( int i=0; i<executors.size(); i++ ) { + executors.get(i).start(); + } + } + // Start our defined Connectors second synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { @@ -526,12 +532,6 @@ } } - synchronized (executors) { - for ( int i=0; i<executors.size(); i++ ) { - executors.get(i).start(); - } - } - // Notify our interested LifecycleListeners lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null); @@ -594,11 +594,27 @@ } } + synchronized (executors) { + for ( int i=0; i<executors.size(); i++ ) { + executors.get(i).stop(); + } + } + if( oname==controller ) { // we registered ourself on init(). // That should be the typical case - this object is just for // backward compat, nobody should bother to load it explicitely Registry.getRegistry(null, null).unregisterComponent(oname); + Executor[] executors = findExecutors(); + for (int i = 0; i < executors.length; i++) { + try { + ObjectName executorObjectName = + new ObjectName(domain + ":type=Executor,name=" + executors[i].getName()); + Registry.getRegistry(null, null).unregisterComponent(executorObjectName); + } catch (Exception e) { + // Ignore (invalid ON, which cannot happen) + } + } } @@ -632,6 +648,15 @@ this.controller=oname; Registry.getRegistry(null, null) .registerComponent(this, oname, null); + + Executor[] executors = findExecutors(); + for (int i = 0; i < executors.length; i++) { + ObjectName executorObjectName = + new ObjectName(domain + ":type=Executor,name=" + executors[i].getName()); + Registry.getRegistry(null, null) + .registerComponent(executors[i], executorObjectName, null); + } + } catch (Exception e) { log.error(sm.getString("standardService.register.failed",domain),e); } Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java?view=diff&rev=521257&r1=521256&r2=521257 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java Thu Mar 22 06:29:30 2007 @@ -155,9 +155,26 @@ lifecycle.removeLifecycleListener(listener); } + // Statistics from the thread pool + public int getActiveCount() { + return (executor != null) ? executor.getActiveCount() : 0; + } - + public long getCompletedTaskCount() { + return (executor != null) ? executor.getCompletedTaskCount() : 0; + } + public int getCorePoolSize() { + return (executor != null) ? executor.getCorePoolSize() : 0; + } + + public int getLargestPoolSize() { + return (executor != null) ? executor.getLargestPoolSize() : 0; + } + + public int getPoolSize() { + return (executor != null) ? executor.getPoolSize() : 0; + } // ---------------------------------------------- TaskQueue Inner Class class TaskQueue extends LinkedBlockingQueue<Runnable> { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]