Package org.hibernate.jmx
Class StatisticsService
java.lang.Object
org.hibernate.jmx.StatisticsService
- All Implemented Interfaces:
StatisticsServiceMBean,Statistics
JMX service for Hibernate statistics
Register this MBean in your JMX server for a specific session factory
Register this MBean in your JMX server with no specific session factory
Register this MBean in your JMX server for a specific session factory
//build the ObjectName you want
Hashtable tb = new Hashtable();
tb.put("type", "statistics");
tb.put("sessionFactory", "myFinancialApp");
ObjectName on = new ObjectName("hibernate", tb);
StatisticsService stats = new StatisticsService();
stats.setSessionFactory(sessionFactory);
server.registerMBean(stats, on);
And call the MBean the way you wantRegister this MBean in your JMX server with no specific session factory
//build the ObjectName you want
Hashtable tb = new Hashtable();
tb.put("type", "statistics");
tb.put("sessionFactory", "myFinancialApp");
ObjectName on = new ObjectName("hibernate", tb);
StatisticsService stats = new StatisticsService();
server.registerMBean(stats, on);
And call the MBean by providing the SessionFactoryJNDIName first.
Then the session factory will be retrieved from JNDI and the statistics
loaded.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()reset all statisticslongThe number of prepared statements that were releasedlongGlobal number of collections fetchedlongGlobal number of collections loadedlongGlobal number of collections recreatedlongGlobal number of collections removedString[]Get the names of all collection rolesGet collection statistics per rolelongGlobal number of collections updatedlongGet the global number of connections asked by the sessions (the actual number of connections used may be much smaller depending whether you use a connection pool or not)longGet global number of entity deleteslongGet global number of entity fetchslongGet global number of entity insertslongGet global number of entity loadsString[]Get the names of all entitiesgetEntityStatistics(String entityName) find entity statistics per namelongGet global number of entity updateslongGet the global number of flush executed by sessions (either implicit or explicit)longThe number of StaleObjectStateExceptions that occurredlongThe number of prepared statements that were acquiredString[]Get all executed query stringslongGet the global number of cached queries successfully retrieved from cachelongGet the global number of cached queries *not* found in cachelongGet the global number of cacheable queries put in cachelongGet global number of executed querieslongGet the time in milliseconds of the slowest query.Get the query string for the slowest query.getQueryStatistics(String hql) Query statistics from query string (HQL or SQL)longGlobal number of cacheable entities/collections successfully retrieved from the cachelongGlobal number of cacheable entities/collections not found in the cache and loaded from the database.longGlobal number of cacheable entities/collections put in the cacheString[]Get all second-level cache region namesgetSecondLevelCacheStatistics(String regionName) Second level cache statistics per regionlongGlobal number of sessions closedlongGlobal number of sessions openedlonglongThe number of transactions we know to have been successfullongThe number of transactions we know to have completedbooleanAre statistics loggedvoidlog in info level the main statisticsvoidUseful to init this MBean wo a JNDI session factory namevoidsetSessionFactoryJNDIName(String sfJNDIName) Publish the statistics of a session factory bound to the default JNDI contextvoidsetStatisticsEnabled(boolean enable) Enable statistics logs (this is a dynamic parameter)
-
Constructor Details
-
StatisticsService
public StatisticsService()
-
-
Method Details
-
setSessionFactoryJNDIName
Description copied from interface:StatisticsServiceMBeanPublish the statistics of a session factory bound to the default JNDI context- Specified by:
setSessionFactoryJNDINamein interfaceStatisticsServiceMBean- Parameters:
sfJNDIName- session factory jndi name- See Also:
-
setSessionFactory
Useful to init this MBean wo a JNDI session factory name- Parameters:
sf- session factory to register
-
clear
public void clear()Description copied from interface:Statisticsreset all statistics- Specified by:
clearin interfaceStatistics- See Also:
-
getEntityStatistics
Description copied from interface:Statisticsfind entity statistics per name- Specified by:
getEntityStatisticsin interfaceStatistics- Parameters:
entityName- entity name- Returns:
- EntityStatistics object
- See Also:
-
getCollectionStatistics
Description copied from interface:StatisticsGet collection statistics per role- Specified by:
getCollectionStatisticsin interfaceStatistics- Parameters:
role- collection role- Returns:
- CollectionStatistics
- See Also:
-
getSecondLevelCacheStatistics
Description copied from interface:StatisticsSecond level cache statistics per region- Specified by:
getSecondLevelCacheStatisticsin interfaceStatistics- Parameters:
regionName- region name- Returns:
- SecondLevelCacheStatistics
- See Also:
-
getQueryStatistics
Description copied from interface:StatisticsQuery statistics from query string (HQL or SQL)- Specified by:
getQueryStatisticsin interfaceStatistics- Parameters:
hql- query string- Returns:
- QueryStatistics
- See Also:
-
getEntityDeleteCount
public long getEntityDeleteCount()Description copied from interface:StatisticsGet global number of entity deletes- Specified by:
getEntityDeleteCountin interfaceStatistics- Returns:
- entity deletion count
- See Also:
-
getEntityInsertCount
public long getEntityInsertCount()Description copied from interface:StatisticsGet global number of entity inserts- Specified by:
getEntityInsertCountin interfaceStatistics- Returns:
- entity insertion count
- See Also:
-
getEntityLoadCount
public long getEntityLoadCount()Description copied from interface:StatisticsGet global number of entity loads- Specified by:
getEntityLoadCountin interfaceStatistics- Returns:
- entity load (from DB)
- See Also:
-
getEntityFetchCount
public long getEntityFetchCount()Description copied from interface:StatisticsGet global number of entity fetchs- Specified by:
getEntityFetchCountin interfaceStatistics- Returns:
- entity fetch (from DB)
- See Also:
-
getEntityUpdateCount
public long getEntityUpdateCount()Description copied from interface:StatisticsGet global number of entity updates- Specified by:
getEntityUpdateCountin interfaceStatistics- Returns:
- entity update
- See Also:
-
getQueryExecutionCount
public long getQueryExecutionCount()Description copied from interface:StatisticsGet global number of executed queries- Specified by:
getQueryExecutionCountin interfaceStatistics- Returns:
- query execution count
- See Also:
-
getQueryCacheHitCount
public long getQueryCacheHitCount()Description copied from interface:StatisticsGet the global number of cached queries successfully retrieved from cache- Specified by:
getQueryCacheHitCountin interfaceStatistics
-
getQueryExecutionMaxTime
public long getQueryExecutionMaxTime()Description copied from interface:StatisticsGet the time in milliseconds of the slowest query.- Specified by:
getQueryExecutionMaxTimein interfaceStatistics
-
getQueryCacheMissCount
public long getQueryCacheMissCount()Description copied from interface:StatisticsGet the global number of cached queries *not* found in cache- Specified by:
getQueryCacheMissCountin interfaceStatistics
-
getQueryCachePutCount
public long getQueryCachePutCount()Description copied from interface:StatisticsGet the global number of cacheable queries put in cache- Specified by:
getQueryCachePutCountin interfaceStatistics
-
getFlushCount
public long getFlushCount()Description copied from interface:StatisticsGet the global number of flush executed by sessions (either implicit or explicit)- Specified by:
getFlushCountin interfaceStatistics- See Also:
-
getConnectCount
public long getConnectCount()Description copied from interface:StatisticsGet the global number of connections asked by the sessions (the actual number of connections used may be much smaller depending whether you use a connection pool or not)- Specified by:
getConnectCountin interfaceStatistics- See Also:
-
getSecondLevelCacheHitCount
public long getSecondLevelCacheHitCount()Description copied from interface:StatisticsGlobal number of cacheable entities/collections successfully retrieved from the cache- Specified by:
getSecondLevelCacheHitCountin interfaceStatistics- See Also:
-
getSecondLevelCacheMissCount
public long getSecondLevelCacheMissCount()Description copied from interface:StatisticsGlobal number of cacheable entities/collections not found in the cache and loaded from the database.- Specified by:
getSecondLevelCacheMissCountin interfaceStatistics- See Also:
-
getSecondLevelCachePutCount
public long getSecondLevelCachePutCount()Description copied from interface:StatisticsGlobal number of cacheable entities/collections put in the cache- Specified by:
getSecondLevelCachePutCountin interfaceStatistics- See Also:
-
getSessionCloseCount
public long getSessionCloseCount()Description copied from interface:StatisticsGlobal number of sessions closed- Specified by:
getSessionCloseCountin interfaceStatistics- See Also:
-
getSessionOpenCount
public long getSessionOpenCount()Description copied from interface:StatisticsGlobal number of sessions opened- Specified by:
getSessionOpenCountin interfaceStatistics- See Also:
-
getCollectionLoadCount
public long getCollectionLoadCount()Description copied from interface:StatisticsGlobal number of collections loaded- Specified by:
getCollectionLoadCountin interfaceStatistics- See Also:
-
getCollectionFetchCount
public long getCollectionFetchCount()Description copied from interface:StatisticsGlobal number of collections fetched- Specified by:
getCollectionFetchCountin interfaceStatistics- See Also:
-
getCollectionUpdateCount
public long getCollectionUpdateCount()Description copied from interface:StatisticsGlobal number of collections updated- Specified by:
getCollectionUpdateCountin interfaceStatistics- See Also:
-
getCollectionRemoveCount
public long getCollectionRemoveCount()Description copied from interface:StatisticsGlobal number of collections removed- Specified by:
getCollectionRemoveCountin interfaceStatistics- See Also:
-
getCollectionRecreateCount
public long getCollectionRecreateCount()Description copied from interface:StatisticsGlobal number of collections recreated- Specified by:
getCollectionRecreateCountin interfaceStatistics- See Also:
-
getStartTime
public long getStartTime()- Specified by:
getStartTimein interfaceStatistics- Returns:
- start time in ms (JVM standards
System.currentTimeMillis()) - See Also:
-
isStatisticsEnabled
public boolean isStatisticsEnabled()Description copied from interface:StatisticsAre statistics logged- Specified by:
isStatisticsEnabledin interfaceStatistics- See Also:
-
setStatisticsEnabled
public void setStatisticsEnabled(boolean enable) Description copied from interface:StatisticsEnable statistics logs (this is a dynamic parameter)- Specified by:
setStatisticsEnabledin interfaceStatistics- See Also:
-
logSummary
public void logSummary()Description copied from interface:Statisticslog in info level the main statistics- Specified by:
logSummaryin interfaceStatistics
-
getCollectionRoleNames
Description copied from interface:StatisticsGet the names of all collection roles- Specified by:
getCollectionRoleNamesin interfaceStatistics
-
getEntityNames
Description copied from interface:StatisticsGet the names of all entities- Specified by:
getEntityNamesin interfaceStatistics
-
getQueries
Description copied from interface:StatisticsGet all executed query strings- Specified by:
getQueriesin interfaceStatistics
-
getSecondLevelCacheRegionNames
Description copied from interface:StatisticsGet all second-level cache region names- Specified by:
getSecondLevelCacheRegionNamesin interfaceStatistics
-
getSuccessfulTransactionCount
public long getSuccessfulTransactionCount()Description copied from interface:StatisticsThe number of transactions we know to have been successful- Specified by:
getSuccessfulTransactionCountin interfaceStatistics
-
getTransactionCount
public long getTransactionCount()Description copied from interface:StatisticsThe number of transactions we know to have completed- Specified by:
getTransactionCountin interfaceStatistics
-
getCloseStatementCount
public long getCloseStatementCount()Description copied from interface:StatisticsThe number of prepared statements that were released- Specified by:
getCloseStatementCountin interfaceStatistics
-
getPrepareStatementCount
public long getPrepareStatementCount()Description copied from interface:StatisticsThe number of prepared statements that were acquired- Specified by:
getPrepareStatementCountin interfaceStatistics
-
getOptimisticFailureCount
public long getOptimisticFailureCount()Description copied from interface:StatisticsThe number of StaleObjectStateExceptions that occurred- Specified by:
getOptimisticFailureCountin interfaceStatistics
-
getQueryExecutionMaxTimeQueryString
Description copied from interface:StatisticsGet the query string for the slowest query.- Specified by:
getQueryExecutionMaxTimeQueryStringin interfaceStatistics
-