[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-3593) be able to configure statistics enablement

John Mazzitelli (JIRA) noreply at atlassian.com
Wed Nov 19 01:50:15 EST 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Mazzitelli updated HHH-3593:
---------------------------------

    Attachment: HHH-3593.patch

I have attached a patch that should provide this functionality.  I did this work on branch_3_2 from today.

Note that this does NOT introduce any JMX compile-time dependencies (due to the requirement that hibernate run in 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 have JDK 1.5+ or JDK 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).

I javadoc'ed/commented most of this so hopefully it makes sense.  Here's a portion of the javadoc that explains the new configuration:

 * <tr>
 *   <td><tt>hibernate.generate_statistics.jmx</tt></td>
 *   <td>If <b>true</b>, the <code>StatisticsService</code> MBean will be deployed.
 *       If this is <code>true</code>, Hibernate must be running in a
 *       JRE 5+ environment or JMX must be installed in classpath.
 *       Setting this to <code>true</code> infers that you want to collect internal
 *       statistics so <code>hibernate.generate_statistics</code> will be ignored
 *       and assumed to have a value of <code>true</code>.</td>
 * </tr>
 * <tr>
 *   <td><tt>hibernate.generate_statistics.jmx.object_name</tt></td>
 *   <td>if <code>hibernate.generate_statistics.jmx</code> is <code>true</code>,
 *       this will be the name the <code>StatisticsService</code> MBean will be
 *       registered under within the MBeanServer.</td>
 * </tr>
 * <tr>
 *   <td><tt>hibernate.generate_statistics.jmx.mbeanserver</tt></td>
 *   <td>if <code>hibernate.generate_statistics.jmx</code> is <code>true</code>,
 *       this will identify the MBeanServer where the <code>StatisticsService</code>
 *       MBean is to be registered. If this value is <b>*platform*</b>, the
 *       <code>ManagementFactory.getPlatformMBeanServer</code>
 *       will be used (only supported on JRE 5 and up). Otherwise, this will be the
 *       name of the MBeanServer's default domain name. If one does not yet exist
 *       with that default domain name, one will be created via
 *       <code>MBeanServerFactory.createMBeanServer</code>.</td>
 * </tr>


> be able to configure statistics enablement
> ------------------------------------------
>
>                 Key: HHH-3593
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core
>            Reporter: John Mazzitelli
>            Priority: Minor
>         Attachments: HHH-3593.patch
>
>
> Right now, in order to enable Hibernate to collect and emit statistics to monitoring tools, your application has to manually execute code similar to the following:
>    StatisticsService mBean = new StatisticsService();
>    SessionFactory sessionFactory = ...get hibernate session factory...
>    mBean.setSessionFactory(sessionFactory);
>    ObjectName objectName = new ObjectName("Hibernate:application=MY_APP_NAME,type=statistics");
>    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>    mbs.registerMBean(mBean, objectName);
>    sessionFactory.getStatistics().setStatisticsEnabled(true);
> It would be nice if this was configurable, so a user of Hibernate doesn't need to write this code.
> For example:
> hibernate.statistics.enabled=true
> hibernate.statistics.objectname=Hibernate:application=MY_APP_NAME,type=statistics
> hibernate.statistics.mbeanserver=*platform*
> This would turn on Hibernate statistics and tell it to register the Statistics MBean in the JVM's platform MBean Server (ManagementFactory.getPlatformMBeanServer). Of course, *platform* would only be valid on Java5 or higher VMs. Note that hibernate will need to allow the object name to be configurable as well.
> Or...
> hibernate.statistics.enabled=true
> hibernate.statistics.objectname=Hibernate:application=MY_APP_NAME,type=statistics
> hibernate.statistics.mbeanserver=my_mbs_name
> This tells Hibernate to register the MBean in the named MBeanServer where the "my_mbs_name" is the default domain name of the MBeanServer you want (if it doesn't exist, Hibernate should create the MBeanServer with the named default domain).
> In fact, I had the Remoting project do something similar, so you can see code that gets the MBeanServer using these two ways by looking at the .patch attached to: https://jira.jboss.org/jira/browse/JBREM-746 and its related fix.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list