[hibernate-dev] exposing statistics easier (HHH-3593 solution)

Emmanuel Bernard emmanuel at hibernate.org
Thu Nov 20 13:57:27 EST 2008

I remember doing something like that when I worked initially on  
Statistics but Gavin did not like it and I did not like it enough to  
argue. I never committed it.

The main problem is that it feels odd for Hibernate to be responsible  
for the Bean Server startup.

If we nevertheless go that path, we need to enhance a few things:
  - sessionFactory.close() should release the Bean Server if it  
started one initially (good citizen)
  - sessionFactory.close() should release the MBean
  - it would be nice to find a better way than  the *platform* hack  
( maybe hibernate.generate_statistics.jmx.mbeanserver.plaform = true )
  - methods using reflections don't really have to break the Java  
conventions, just name them getPlatformBeanServer(), that's what they  
are doing.

On  Nov 19, 2008, at 06:49, John Mazzitelli wrote:

> I recently added support to Jopr, The JBoss management platform  
> project ( http://www.jboss.org/jopr ) to be able to monitor  
> Hibernate via the Hibernate Statistics MBean.
> For background, see my blog entry: http://management-platform.blogspot.com/2008/11/monitoring-hibernate.html
> and more specifically, see the demo flash: https://docs.jbosson.redhat.com/confluence/display/JON2/Demo-MonitoringHibernate
> If you watch that demo, you can see how useful the Hibernate  
> Statistics data can be (e.g. when used by external management tools  
> like Jopr you can track the performance of Hibernate over time, send  
> alerts based on that performance data, etc. etc.).
> But for users to be able to monitor their Hibernate applications  
> from an external management tool, it isn't enough for them to  
> specify the "hibernate.generate_statistics" configuration setting.   
> They must expose those statistics via JMX; however, that puts a  
> burden on the Hibernate developer to write special code to do this  
> (as the example code in the blog illustrates - see Max's comments on  
> my blog and my responses also).
> Out of that, I submitted this JIRA:
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593
> Last night I wrote the code that implements this enhancement request  
> and attached the patch to that JIRA. The short of it is, the  
> Hibernate developer no longer has to write any Java code to expose  
> the statistics via JMX, all you have to do is set these  
> configuration settings:
> hibernate.generate_statistics.jmx=true
> hibernate 
> .generate_statistics 
> .jmx.object_name=hibernate:type=statistics,application=foo
> hibernate.generate_statistics.jmx.mbeanserver=*platform*
> If you set those, statistics generation will be turned on, the  
> Hibernate Statistics MBean will be exposed via JMX and if you  
> enabled the VM for remote JMX, you can immediately begin to monitor  
> Hibernate (you'll even see the Hibernate MBean via jconsole, though  
> things like Jopr will provide better functionality like viewing  
> historical stat data, alerting and the like).
> As the JIRA mentions, this patch does NOT introduce any JMX compile- 
> time dependencies (due to the requirement that Hibernate be able to  
> support JDK 1.4). Therefore, you will not see any  
> "javax.management.*" imports or classes being used directly (they  
> are used via reflection). However, if you enable this JMX statistics  
> feature, obviously, you must run in JRE 5+ or JRE 1.4 + JMX  
> libraries - if you do not, this code will log error messages saying  
> what the problem is and simply disable the JMX stats capability (but  
> otherwise, hibernate works normally).
> Any suggestions how I might further this along to get it merged? Or  
> is this patch good enough for some Hibernate developer to merge it  
> in and take it over?
> John Mazz
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev

More information about the hibernate-dev mailing list