-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chuck,

On 7/31/14, 1:22 PM, Caldarale, Charles R wrote:
>> From: Igal @ getRailo.org [mailto:i...@getrailo.org] Subject: Re:
>> Programmatically retrieve number of tomcat connections
> 
>> 1) you create a class that implements the Filter interface and
>> maintains the count in an AtomicLong object.
> 
>> 2) you increment the AtomicLong before the call to
>> chain.doFilter() and decrement it after that call.
> 
> This has nothing to do with the number of connections.
> 
>> another way I can think of is to get all the threads in the JVM
>> with Thread.getAllStackTraces(), loop over them, and check their
>> names for example.
> 
> Which also has little to do with the number of connections,
> especially when using NIO.
> 
> You may be able to dig the number of connections out via an
> internal JMX call.  This is, of course, Tomcat specific, but avoids
> trying to invoke Tomcat's internal classes.

+1

IMO, this is the right way to do it. You don't have to use a JMX
connection, even: you can just query the local JMX server for the bean
object and interrogate it.

Lance, look at the source code to the JMXProxyServlet and you can see
how to fetch JMX beans from the server. Then, just write some code to
do the same thing for the bean you're looking for and grab the data
you want.

Or, you could just use the JMX proxy servlet directly to fetch the
data you want.

Why do you want this information from /inside/ the application, rather
than outside of it?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJT2nzeAAoJEBzwKT+lPKRYZqkP/0y/m6XFlb689l64rHzmH9ia
pVjtPkoTGTNFNEcYbYEM1yK2n56Ty9kbzP0svhNRJPfsBghvhXOi/qG7IQ6cxTq0
skFQ+ybCXCFuUviaTUdrzYbrB+AkKRT3K9gnjOHdRetlLGCJffmDPVHiUyQekAMF
s4jHBaEJ466rrScfQtW8hMEA+S8ra9gRDkYV2h9jjwuXohqAIc6qgnDsUBlzQzgp
JceP4PjuaDr1KAONGY+tJ7fLxHwf2GLs0D7urfIRPH9dlxk3pv2O0JzzXpk2pXsX
yxm02JSQGX1jk1EbNNqzB8+eUf7coMWseRfbRGuvB2GgB4zWGeq9qFwgsl83FT1k
RpSUf6XWrXduVw9FHev5Usus/riqP71lZjZAg1EgM/DJXdXmcfIOElQrOCI0nTra
WMuB+p1XSLPf57RffsjkMy4SyqQjcryK4Z6pjYHiezYe//7hCqpMQeFhx4tIRh6g
jWSsO0ayGmurmzX0LjteYSR9ru6tFlxqQ+2taGR0ZgdCmiVwfc4CTLj7orgRojJg
XsD5K0jnyIXbvXdgdD0qfWs4eJIDBgquRX+A97qUAtoLOqBy/s9hv/OHIYfqlbbW
KOxSm2YlJ/TYm+pZOKJlHYh7W1+tErq7C+2AqqD78bytgetCYEHihYmIGRP0HpiP
zr2jw9wnMaGJcpUTPwN9
=2Vqm
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to