EnkiHibernateStatisticsLogging

From LucidDB Wiki
Jump to: navigation, search

Contents

Overview

Enki/Hibernate can be configured to periodically log Hibernate session factory and second-level cache statistics.

As future enhancement it would be useful to have JMX support for obtaining statistics.

Log File Configuration

Modify the repository storage configuration properties file to include the following property:

org.eigenbase.enki.hibernate.periodicStats=60

The value indicates the time that will elapsed between bursts of statistics logging. A sample log (timestamps stripped for bevity) follows:

org.hibernate.stat.StatisticsImpl logSummary INFO: Logging statistics....
org.hibernate.stat.StatisticsImpl logSummary INFO: start time: 1225996894307
org.hibernate.stat.StatisticsImpl logSummary INFO: sessions opened: 384
org.hibernate.stat.StatisticsImpl logSummary INFO: sessions closed: 383
org.hibernate.stat.StatisticsImpl logSummary INFO: transactions: 470
org.hibernate.stat.StatisticsImpl logSummary INFO: successful transactions: 56
org.hibernate.stat.StatisticsImpl logSummary INFO: optimistic lock failures: 0
org.hibernate.stat.StatisticsImpl logSummary INFO: flushes: 109
org.hibernate.stat.StatisticsImpl logSummary INFO: connections obtained: 470
org.hibernate.stat.StatisticsImpl logSummary INFO: statements prepared: 1076
org.hibernate.stat.StatisticsImpl logSummary INFO: statements closed: 1076
org.hibernate.stat.StatisticsImpl logSummary INFO: second level cache puts: 1302
org.hibernate.stat.StatisticsImpl logSummary INFO: second level cache hits: 11813
org.hibernate.stat.StatisticsImpl logSummary INFO: second level cache misses: 92
org.hibernate.stat.StatisticsImpl logSummary INFO: entities loaded: 1142
org.hibernate.stat.StatisticsImpl logSummary INFO: entities updated: 361
org.hibernate.stat.StatisticsImpl logSummary INFO: entities inserted: 431
org.hibernate.stat.StatisticsImpl logSummary INFO: entities deleted: 0
org.hibernate.stat.StatisticsImpl logSummary INFO: entities fetched (minimize this): 180
org.hibernate.stat.StatisticsImpl logSummary INFO: collections loaded: 403
org.hibernate.stat.StatisticsImpl logSummary INFO: collections updated: 32
org.hibernate.stat.StatisticsImpl logSummary INFO: collections removed: 0
org.hibernate.stat.StatisticsImpl logSummary INFO: collections recreated: 126
org.hibernate.stat.StatisticsImpl logSummary INFO: collections fetched (minimize this): 59
org.hibernate.stat.StatisticsImpl logSummary INFO: queries executed to database: 147
org.hibernate.stat.StatisticsImpl logSummary INFO: query cache puts: 147
org.hibernate.stat.StatisticsImpl logSummary INFO: query cache hits: 3269
org.hibernate.stat.StatisticsImpl logSummary INFO: query cache misses: 147
org.hibernate.stat.StatisticsImpl logSummary INFO: max query time: 163ms
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: org.hibernate.cache.StandardQueryCache: elements: 61
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: FEM_ENKI_QUERY: elements: 18
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: FEM_ENKI: elements: 1255
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: org.hibernate.cache.UpdateTimestampsCache: elements: 27

Note that two different loggers are used. One (org.hibernate.stat.StatisticsImpl) belongs to Hibernate. The other (org.eigenbase.enki.hibernate.HibernateMDRepository) belongs to Enki/Hibernate and reports second-level cache statistics.

Memory Usage Configuration

Additionally, the repository can be configured to estimate second-level cache memory usage by adding the following property to the same file:

org.eigenbase.enki.hibernate.periodicStats.memStats=true

Note that memory usage estimation requires serializing the second-level cache, and that serialization is an expensive operation.

Enabling memory usage logging changes the second-level cache statistics (timestamps and session factory statistics stripped for brevity):

org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: org.hibernate.cache.StandardQueryCache: elements: 97 size in memory: 244818
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: FEM_ENKI_QUERY: elements: 15 size in memory: 39151
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: FEM_ENKI: elements: 1286 size in memory: 1842890
org.eigenbase.enki.hibernate.HibernateMDRepository logPeriodicStats INFO: stats: cache region: org.hibernate.cache.UpdateTimestampsCache: elements: 26 size in memory: 7923

Memory usage estimates are in bytes.

JMX Management Beans

Enki automatically registers JMX MBeans with an MBean server. By default, Enki generates names for each EnkiMDRepository instance as follows:

  org.eigenbase.enki.mbean:type=EnkiRepository;name=<PROVIDER_TYPE>#<identity-hashcode>

For example:

  org.eigenbase.enki.mbean:type=EnkiRepository;name=ENKI_HIBERNATE#24fa7c
  org.eigenbase.enki.mbean:type=EnkiRepository;name=NETBEANS_MDR#1bcc2f

Note that the identity hash code is JVM dependent and will change each time the repository is instantiated. That is, it will vary across JVM restarts and it will change during a single JVM's execution if the repository is shutdown and re-instantiated.

The name can be made static by specifying the storage property org.eigenbase.enki.repositoryName with a name unique to the repository instance. For example, specifying

  org.eigenbase.enki.repositoryName=SampleRepository

will cause the JMX MBean's name to be

  org.eigenbase.enki.mbean:type=EnkiRepository;name=SampleRepository

If multiple repository instances have the same name within a JVM, MBean registration and, consequently, repository instantiation will fail.

The repository MBeans provide the following attributes:

MBean Attributes
Property Description Implemented By
ProviderType String representation of provider type All
StorageProperties Tabular data containing the storage properties used to configure the repository All
ExtentNames A string array of available extent names All
PerformanceStatistics Tabular data containing key performanance statistics (see operations). Enki/Hibernate only

The repository MBeans provide the following operations:

MBean Operations
Operation Description Implemented By
getExtentAnnotation(String) Returns the given extent's annotation or null if the extent is not annotated or does not exist. All
enablePerformanceStatistics Enables collection of performance statistics. Enki/Hibernate only
disablePerformanceStatistics Disables collection of performance statistics. Enki/Hibernate only

All repository MBeans present all the attributes and operations, but if the the underlying repository does not support the attribute or operation it will return no data or perform no action.

Product Documentation