Author: markt Date: Thu Nov 1 23:03:08 2018 New Revision: 1845519 URL: http://svn.apache.org/viewvc?rev=1845519&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62871 Improve MBeans for Endpoint instances (type ThreadPool in JMX) by using explicit declaration of attributes and operations rather than relying on introspection. Add a new MBean to expose the Socketproperties values.
Added: tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml (with props) Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1845519&r1=1845518&r2=1845519&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Thu Nov 1 23:03:08 2018 @@ -1085,6 +1085,11 @@ public abstract class AbstractEndpoint<S oname = new ObjectName(domain + ":type=ThreadPool,name=\"" + getName() + "\""); Registry.getRegistry(null, null).registerComponent(this, oname, null); + ObjectName socketPropertiesOname = new ObjectName(domain + + ":type=ThreadPool,name=\"" + getName() + "\",subType=SocketProperties"); + socketProperties.setObjectName(socketPropertiesOname); + Registry.getRegistry(null, null).registerComponent(socketProperties, socketPropertiesOname, null); + for (SSLHostConfig sslHostConfig : findSslHostConfigs()) { registerJmx(sslHostConfig); } @@ -1203,6 +1208,7 @@ public abstract class AbstractEndpoint<S } Registry registry = Registry.getRegistry(null, null); registry.unregisterComponent(oname); + registry.unregisterComponent(socketProperties.getObjectName()); for (SSLHostConfig sslHostConfig : findSslHostConfigs()) { unregisterJmx(sslHostConfig); } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java?rev=1845519&r1=1845518&r2=1845519&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java Thu Nov 1 23:03:08 2018 @@ -24,6 +24,8 @@ import java.net.StandardSocketOptions; import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocketChannel; +import javax.management.ObjectName; + /** * Properties that can be set in the <Connector> element * in server.xml. All properties are prefixed with "socket." @@ -173,6 +175,9 @@ public class SocketProperties { */ protected int unlockTimeout = 250; + private ObjectName oname = null; + + public void setProperties(Socket socket) throws SocketException{ if (rxBufSize != null) socket.setReceiveBufferSize(rxBufSize.intValue()); @@ -421,5 +426,11 @@ public class SocketProperties { this.unlockTimeout = unlockTimeout; } + void setObjectName(ObjectName oname) { + this.oname = oname; + } + ObjectName getObjectName() { + return oname; + } } Added: tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml?rev=1845519&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml (added) +++ tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml Thu Nov 1 23:03:08 2018 @@ -0,0 +1,696 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<mbeans-descriptors> + + <mbean name="NioEndpoint" + className="org.apache.catalina.mbeans.ClassNameMBean" + domain="Catalina" + group="ThreadPool" + type="org.apache.tomcat.util.net.NioEndpoint"> + + <attribute name="acceptCount" + type="int"/> + + <attribute name="acceptorThreadCount" + type="int"/> + + <attribute name="acceptorThreadPriority" + type="int"/> + + <attribute name="alpnSupported" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="bindOnInit" + type="boolean"/> + + <attribute name="connectionCount" + type="long" + writeable="false"/> + + <attribute name="connectionLinger" + type="int"/> + + <attribute name="connectionTimeout" + type="int"/> + + <attribute name="currentThreadCount" + type="int" + writeable="false"/> + + <attribute name="currentThreadsBusy" + type="int" + writeable="false"/> + + <attribute name="daemon" + type="boolean"/> + + <attribute name="defaultSSLHostConfigName" + type="java.lang.String"/> + + <attribute name="deferAccept" + type="boolean" + writeable="false"/> + + <attribute name="domain" + type="java.lang.String"/> + + <attribute name="executorTerminationTimeoutMillis" + type="long"/> + + <attribute name="keepAliveCount" + type="int" + writeable="false"/> + + <attribute name="keepAliveTimeout" + type="int"/> + + <attribute name="localPort" + type="int" + writeable="false"/> + + <attribute name="maxConnections" + type="int"/> + + <attribute name="maxKeepAliveRequests" + type="int"/> + + <attribute name="maxThreads" + type="int"/> + + <attribute name="minSpareThreads" + type="int"/> + + <attribute name="modelerType" + type="java.lang.String" + writeable="false"/> + + <attribute name="name" + type="java.lang.String"/> + + <attribute name="paused" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="pollerThreadCount" + type="int"/> + + <attribute name="pollerThreadPriority" + type="int"/> + + <attribute name="port" + type="int"/> + + <attribute name="portOffset" + type="int"/> + + <attribute name="portWithOffset" + type="int" + writeable="false"/> + + <attribute name="running" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="sSLEnabled" + type="boolean" + is="true"/> + + <attribute name="selectorTimeout" + type="long"/> + + <attribute name="sniParseLimit" + type="int"/> + + <attribute name="sslImplementation" + type="org.apache.tomcat.util.net.SSLImplementation" + writeable="false"/> + + <attribute name="sslImplementationName" + type="java.lang.String"/> + + <attribute name="tcpNoDelay" + type="boolean"/> + + <attribute name="threadPriority" + type="int"/> + + <attribute name="useInheritedChannel" + type="boolean"/> + + <attribute name="useSendfile" + type="boolean"/> + + <operation name="addNegotiatedProtocol" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="bind" + returnType="void"/> + + <operation name="closeServerSocketGraceful" + returnType="void"/> + + <operation name="createExecutor" + returnType="void"/> + + <operation name="destroy" + returnType="void"/> + + <operation name="findSslHostConfigs" + returnType="[Lorg.apache.tomcat.util.net.SSLHostConfig;"/> + + <operation name="getAttribute" + returnType="java.lang.Object"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="getProperty" + returnType="java.lang.String"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="hasNegotiableProtocols" + returnType="boolean"/> + + <operation name="init" + returnType="void"/> + + <operation name="pause" + returnType="void"/> + + <operation name="reloadSslHostConfig" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="reloadSslHostConfigs" + returnType="void"/> + + <operation name="removeSslHostConfig" + returnType="org.apache.tomcat.util.net.SSLHostConfig"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="resume" + returnType="void"/> + + <operation name="setProperty" + returnType="boolean"> + <parameter name="param0" + type="java.lang.String"/> + <parameter name="param1" + type="java.lang.String"/> + </operation> + + <operation name="shutdownExecutor" + returnType="void"/> + + <operation name="start" + returnType="void"/> + + <operation name="startInternal" + returnType="void"/> + + <operation name="stop" + returnType="void"/> + + <operation name="stopInternal" + returnType="void"/> + + <operation name="unbind" + returnType="void"/> + + </mbean> + + <mbean name="Nio2Endpoint" + className="org.apache.catalina.mbeans.ClassNameMBean" + domain="Catalina" + group="ThreadPool" + type="org.apache.tomcat.util.net.Nio2Endpoint"> + + <attribute name="acceptCount" + type="int"/> + + <attribute name="acceptorThreadCount" + type="int"/> + + <attribute name="acceptorThreadPriority" + type="int"/> + + <attribute name="alpnSupported" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="bindOnInit" + type="boolean"/> + + <attribute name="connectionCount" + type="long" + writeable="false"/> + + <attribute name="connectionLinger" + type="int"/> + + <attribute name="connectionTimeout" + type="int"/> + + <attribute name="currentThreadCount" + type="int" + writeable="false"/> + + <attribute name="currentThreadsBusy" + type="int" + writeable="false"/> + + <attribute name="daemon" + type="boolean"/> + + <attribute name="defaultSSLHostConfigName" + type="java.lang.String"/> + + <attribute name="deferAccept" + type="boolean" + writeable="false"/> + + <attribute name="domain" + type="java.lang.String"/> + + <attribute name="executorTerminationTimeoutMillis" + type="long"/> + + <attribute name="keepAliveCount" + type="int" + writeable="false"/> + + <attribute name="keepAliveTimeout" + type="int"/> + + <attribute name="localPort" + type="int" + writeable="false"/> + + <attribute name="maxConnections" + type="int"/> + + <attribute name="maxKeepAliveRequests" + type="int"/> + + <attribute name="maxThreads" + type="int"/> + + <attribute name="minSpareThreads" + type="int"/> + + <attribute name="modelerType" + type="java.lang.String" + writeable="false"/> + + <attribute name="name" + type="java.lang.String"/> + + <attribute name="paused" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="port" + type="int"/> + + <attribute name="portOffset" + type="int"/> + + <attribute name="portWithOffset" + type="int" + writeable="false"/> + + <attribute name="running" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="sSLEnabled" + type="boolean" + is="true"/> + + <attribute name="sniParseLimit" + type="int"/> + + <attribute name="sslImplementation" + type="org.apache.tomcat.util.net.SSLImplementation" + writeable="false"/> + + <attribute name="sslImplementationName" + type="java.lang.String"/> + + <attribute name="tcpNoDelay" + type="boolean"/> + + <attribute name="threadPriority" + type="int"/> + + <attribute name="useSendfile" + type="boolean"/> + + <operation name="addNegotiatedProtocol" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="bind" + returnType="void"/> + + <operation name="closeServerSocketGraceful" + returnType="void"/> + + <operation name="createExecutor" + returnType="void"/> + + <operation name="destroy" + returnType="void"/> + + <operation name="findSslHostConfigs" + returnType="[Lorg.apache.tomcat.util.net.SSLHostConfig;"/> + + <operation name="getAttribute" + returnType="java.lang.Object"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="getProperty" + returnType="java.lang.String"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="hasNegotiableProtocols" + returnType="boolean"/> + + <operation name="init" + returnType="void"/> + + <operation name="pause" + returnType="void"/> + + <operation name="reloadSslHostConfig" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="reloadSslHostConfigs" + returnType="void"/> + + <operation name="removeSslHostConfig" + returnType="org.apache.tomcat.util.net.SSLHostConfig"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="resume" + returnType="void"/> + + <operation name="setProperty" + returnType="boolean"> + <parameter name="param0" + type="java.lang.String"/> + <parameter name="param1" + type="java.lang.String"/> + </operation> + + <operation name="shutdownExecutor" + returnType="void"/> + + <operation name="start" + returnType="void"/> + + <operation name="startInternal" + returnType="void"/> + + <operation name="stop" + returnType="void"/> + + <operation name="stopInternal" + returnType="void"/> + + <operation name="unbind" + returnType="void"/> + + </mbean> + + <mbean name="AprEndpoint" + className="org.apache.catalina.mbeans.ClassNameMBean" + domain="Catalina" + group="ThreadPool" + type="org.apache.tomcat.util.net.AprEndpoint"> + + <attribute name="acceptCount" + type="int"/> + + <attribute name="acceptorThreadCount" + type="int"/> + + <attribute name="acceptorThreadPriority" + type="int"/> + + <attribute name="alpnSupported" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="bindOnInit" + type="boolean"/> + + <attribute name="connectionCount" + type="long" + writeable="false"/> + + <attribute name="connectionLinger" + type="int"/> + + <attribute name="connectionTimeout" + type="int"/> + + <attribute name="currentThreadCount" + type="int" + writeable="false"/> + + <attribute name="currentThreadsBusy" + type="int" + writeable="false"/> + + <attribute name="daemon" + type="boolean"/> + + <attribute name="defaultSSLHostConfigName" + type="java.lang.String"/> + + <attribute name="deferAccept" + type="boolean"/> + + <attribute name="domain" + type="java.lang.String"/> + + <attribute name="executorTerminationTimeoutMillis" + type="long"/> + + <attribute name="ipv6v6only" + type="boolean"/> + + <attribute name="keepAliveCount" + type="int" + writeable="false"/> + + <attribute name="keepAliveTimeout" + type="int"/> + + <attribute name="localPort" + type="int" + writeable="false"/> + + <attribute name="maxConnections" + type="int"/> + + <attribute name="maxKeepAliveRequests" + type="int"/> + + <attribute name="maxThreads" + type="int"/> + + <attribute name="minSpareThreads" + type="int"/> + + <attribute name="modelerType" + type="java.lang.String" + writeable="false"/> + + <attribute name="name" + type="java.lang.String"/> + + <attribute name="paused" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="pollTime" + type="int"/> + + <attribute name="port" + type="int"/> + + <attribute name="portOffset" + type="int"/> + + <attribute name="portWithOffset" + type="int" + writeable="false"/> + + <attribute name="running" + type="boolean" + writeable="false" + is="true"/> + + <attribute name="sSLEnabled" + type="boolean" + is="true"/> + + <attribute name="sendfileCount" + type="int" + writeable="false"/> + + <attribute name="sendfileSize" + type="int"/> + + <attribute name="tcpNoDelay" + type="boolean"/> + + <attribute name="threadPriority" + type="int"/> + + <attribute name="useSendfile" + type="boolean"/> + + <operation name="addNegotiatedProtocol" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="bind" + returnType="void"/> + + <operation name="closeServerSocketGraceful" + returnType="void"/> + + <operation name="createExecutor" + returnType="void"/> + + <operation name="destroy" + returnType="void"/> + + <operation name="findSslHostConfigs" + returnType="[Lorg.apache.tomcat.util.net.SSLHostConfig;"/> + + <operation name="getAttribute" + returnType="java.lang.Object"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="getProperty" + returnType="java.lang.String"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="getSslContext" + returnType="long"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="hasNegotiableProtocols" + returnType="boolean"/> + + <operation name="init" + returnType="void"/> + + <operation name="pause" + returnType="void"/> + + <operation name="reloadSslHostConfig" + returnType="void"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="reloadSslHostConfigs" + returnType="void"/> + + <operation name="removeSslHostConfig" + returnType="org.apache.tomcat.util.net.SSLHostConfig"> + <parameter name="param0" + type="java.lang.String"/> + </operation> + + <operation name="resume" + returnType="void"/> + + <operation name="setProperty" + returnType="boolean"> + <parameter name="param0" + type="java.lang.String"/> + <parameter name="param1" + type="java.lang.String"/> + </operation> + + <operation name="shutdownExecutor" + returnType="void"/> + + <operation name="start" + returnType="void"/> + + <operation name="startInternal" + returnType="void"/> + + <operation name="stop" + returnType="void"/> + + <operation name="stopInternal" + returnType="void"/> + + <operation name="unbind" + returnType="void"/> + + </mbean> + +</mbeans-descriptors> + + Propchange: tomcat/trunk/java/org/apache/tomcat/util/net/mbeans-descriptors.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java?rev=1845519&r1=1845518&r2=1845519&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java (original) +++ tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java Thu Nov 1 23:03:08 2018 @@ -134,6 +134,9 @@ public class TestRegistration extends To + ObjectName.quote(ADDRESS), "Tomcat:type=ThreadPool,name=" + ObjectName.quote("http-" + type + "-" + ADDRESS + "-" + port), + "Tomcat:type=ThreadPool,name=" + + ObjectName.quote("http-" + type + "-" + ADDRESS + "-" + port) + + ",subType=SocketProperties", }; } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1845519&r1=1845518&r2=1845519&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Nov 1 23:03:08 2018 @@ -188,6 +188,12 @@ Ensure open sockets etc. are cleaned up if the socket binding process fails. (markt) </fix> + <fix> + <bug>62871</bug>: Improve MBeans for Endpoint instances (type + <code>ThreadPool</code> in JMX) by using explicit declaration of + attributes and operations rather than relying on introspection. Add a + new MBean to expose the <code>Socketproperties</code> values. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org