views:

500

answers:

2

Is there any tool which would allow for monitoring Hibernate 2nd level cache usage? I know that I could use Hibernate API for retrieving such information. But what should I do when I have application which doesn't read the information itself, and I can't modify it? Is there any way to read cache statistics from the outside of the application?

+3  A: 

If your 2nd level cache is an EhCache, then you can read cache status from its MBean.

See 'JMX Management and Monitoring' in the ehcache documentation: http://ehcache.org/documentation/jmx.html

Tomas Forsman
+4  A: 

Quoting Hibernate documentation:

3.4.6. Hibernate statistics

If you enable hibernate.generate_statistics, Hibernate exposes a number of metrics that are useful when tuning a running system via SessionFactory.getStatistics(). Hibernate can even be configured to expose these statistics via JMX. Read the Javadoc of the interfaces in org.hibernate.stats for more information.

You'll find the org.hibernate.stats package-summary here.

For the JMX part, have a look at Publishing statistics through JMX.

For more advanced stuff, you'll have to rely on specific features from your cache provider.

Pascal Thivent
Link changed: http://docs.jboss.org/hibernate/stable/core/api/
Ondra Žižka
@Ondra Thanks, link updated (why the hell did JBoss not implement some permanent redirect to the new location, there are so many links on the net pointing to nowhere now, this goes against all best practices...).
Pascal Thivent
Well, JBoss.org has underwent big structural changes, and unfortunatelly, link preservation was not the priority to be kept in mind when there's only few people taking care of the whole web...
Ondra Žižka
I wanted to send a redirection request to JBoss.org team, but I don't know the original link :) Do you still have it, accidentally?
Ondra Žižka
@Ondra The original link was https://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/package-summary.html. Ideally, a redirect should be done for both the javadoc and the reference guide, something like https://www.hibernate.org/hib_docs/v3/ --> http://docs.jboss.org/hibernate/core/3.3/
Pascal Thivent