Tool for monitoring Hibernate cache usage

2019-04-02 02:00发布

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?

4条回答
太酷不给撩
2楼-- · 2019-04-02 02:14

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.

查看更多
狗以群分
3楼-- · 2019-04-02 02:14

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

查看更多
仙女界的扛把子
5楼-- · 2019-04-02 02:36

There is a tool for monitoring hibernate's cache that has been exposed through JMX. Its called hibernate-jconsole and can be downloaded here - http://hibernate-jcons.sourceforge.net/

查看更多
登录 后发表回答