|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.hibernate.jmx.StatisticsService
public class StatisticsService
JMX service for Hibernate statistics
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 want
//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 | |
|---|---|
StatisticsService()
|
|
| Method Summary | |
|---|---|
void |
clear()
reset all statistics |
long |
getCloseStatementCount()
The number of prepared statements that were released |
long |
getCollectionFetchCount()
Global number of collections fetched |
long |
getCollectionLoadCount()
Global number of collections loaded |
long |
getCollectionRecreateCount()
Global number of collections recreated |
long |
getCollectionRemoveCount()
Global number of collections removed |
String[] |
getCollectionRoleNames()
Get the names of all collection roles |
CollectionStatistics |
getCollectionStatistics(String role)
Get collection statistics per role |
long |
getCollectionUpdateCount()
Global number of collections updated |
long |
getConnectCount()
Get 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) |
long |
getEntityDeleteCount()
Get global number of entity deletes |
long |
getEntityFetchCount()
Get global number of entity fetchs |
long |
getEntityInsertCount()
Get global number of entity inserts |
long |
getEntityLoadCount()
Get global number of entity loads |
String[] |
getEntityNames()
Get the names of all entities |
EntityStatistics |
getEntityStatistics(String entityName)
find entity statistics per name |
long |
getEntityUpdateCount()
Get global number of entity updates |
long |
getFlushCount()
Get the global number of flush executed by sessions (either implicit or explicit) |
long |
getOptimisticFailureCount()
The number of StaleObjectStateExceptions that occurred |
long |
getPrepareStatementCount()
The number of prepared statements that were acquired |
String[] |
getQueries()
Get all executed query strings |
long |
getQueryCacheHitCount()
Get the global number of cached queries successfully retrieved from cache |
long |
getQueryCacheMissCount()
Get the global number of cached queries *not* found in cache |
long |
getQueryCachePutCount()
Get the global number of cacheable queries put in cache |
long |
getQueryExecutionCount()
Get global number of executed queries |
long |
getQueryExecutionMaxTime()
Get the time in milliseconds of the slowest query. |
String |
getQueryExecutionMaxTimeQueryString()
Get the query string for the slowest query. |
QueryStatistics |
getQueryStatistics(String hql)
Query statistics from query string (HQL or SQL) |
long |
getSecondLevelCacheHitCount()
Global number of cacheable entities/collections successfully retrieved from the cache |
long |
getSecondLevelCacheMissCount()
Global number of cacheable entities/collections not found in the cache and loaded from the database. |
long |
getSecondLevelCachePutCount()
Global number of cacheable entities/collections put in the cache |
String[] |
getSecondLevelCacheRegionNames()
Get all second-level cache region names |
SecondLevelCacheStatistics |
getSecondLevelCacheStatistics(String regionName)
Second level cache statistics per region |
long |
getSessionCloseCount()
Global number of sessions closed |
long |
getSessionOpenCount()
Global number of sessions opened |
long |
getStartTime()
|
long |
getSuccessfulTransactionCount()
The number of transactions we know to have been successful |
long |
getTransactionCount()
The number of transactions we know to have completed |
boolean |
isStatisticsEnabled()
Are statistics logged |
void |
logSummary()
log in info level the main statistics |
void |
setSessionFactory(SessionFactory sf)
Useful to init this MBean wo a JNDI session factory name |
void |
setSessionFactoryJNDIName(String sfJNDIName)
Publish the statistics of a session factory bound to the default JNDI context |
void |
setStatisticsEnabled(boolean enable)
Enable statistics logs (this is a dynamic parameter) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StatisticsService()
| Method Detail |
|---|
public void setSessionFactoryJNDIName(String sfJNDIName)
StatisticsServiceMBean
setSessionFactoryJNDIName in interface StatisticsServiceMBeansfJNDIName - session factory jndi nameStatisticsServiceMBean.setSessionFactoryJNDIName(java.lang.String)public void setSessionFactory(SessionFactory sf)
sf - session factory to registerpublic void clear()
Statistics
clear in interface StatisticsStatistics.clear()public EntityStatistics getEntityStatistics(String entityName)
Statistics
getEntityStatistics in interface StatisticsentityName - entity name
Statistics.getEntityStatistics(java.lang.String)public CollectionStatistics getCollectionStatistics(String role)
Statistics
getCollectionStatistics in interface Statisticsrole - collection role
Statistics.getCollectionStatistics(java.lang.String)public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName)
Statistics
getSecondLevelCacheStatistics in interface StatisticsregionName - region name
Statistics.getSecondLevelCacheStatistics(java.lang.String)public QueryStatistics getQueryStatistics(String hql)
Statistics
getQueryStatistics in interface Statisticshql - query string
Statistics.getQueryStatistics(java.lang.String)public long getEntityDeleteCount()
Statistics
getEntityDeleteCount in interface StatisticsStatistics.getEntityDeleteCount()public long getEntityInsertCount()
Statistics
getEntityInsertCount in interface StatisticsStatistics.getEntityInsertCount()public long getEntityLoadCount()
Statistics
getEntityLoadCount in interface StatisticsStatistics.getEntityLoadCount()public long getEntityFetchCount()
Statistics
getEntityFetchCount in interface StatisticsStatistics.getEntityFetchCount()public long getEntityUpdateCount()
Statistics
getEntityUpdateCount in interface StatisticsStatistics.getEntityUpdateCount()public long getQueryExecutionCount()
Statistics
getQueryExecutionCount in interface StatisticsStatistics.getQueryExecutionCount()public long getQueryCacheHitCount()
Statistics
getQueryCacheHitCount in interface Statisticspublic long getQueryExecutionMaxTime()
Statistics
getQueryExecutionMaxTime in interface Statisticspublic long getQueryCacheMissCount()
Statistics
getQueryCacheMissCount in interface Statisticspublic long getQueryCachePutCount()
Statistics
getQueryCachePutCount in interface Statisticspublic long getFlushCount()
Statistics
getFlushCount in interface StatisticsStatistics.getFlushCount()public long getConnectCount()
Statistics
getConnectCount in interface StatisticsStatistics.getConnectCount()public long getSecondLevelCacheHitCount()
Statistics
getSecondLevelCacheHitCount in interface StatisticsStatistics.getSecondLevelCacheHitCount()public long getSecondLevelCacheMissCount()
Statistics
getSecondLevelCacheMissCount in interface StatisticsStatistics.getSecondLevelCacheMissCount()public long getSecondLevelCachePutCount()
Statistics
getSecondLevelCachePutCount in interface StatisticsStatistics.getSecondLevelCachePutCount()public long getSessionCloseCount()
Statistics
getSessionCloseCount in interface StatisticsStatistics.getSessionCloseCount()public long getSessionOpenCount()
Statistics
getSessionOpenCount in interface StatisticsStatistics.getSessionOpenCount()public long getCollectionLoadCount()
Statistics
getCollectionLoadCount in interface StatisticsStatistics.getCollectionLoadCount()public long getCollectionFetchCount()
Statistics
getCollectionFetchCount in interface StatisticsStatistics.getCollectionFetchCount()public long getCollectionUpdateCount()
Statistics
getCollectionUpdateCount in interface StatisticsStatistics.getCollectionUpdateCount()public long getCollectionRemoveCount()
Statistics
getCollectionRemoveCount in interface StatisticsStatistics.getCollectionRemoveCount()public long getCollectionRecreateCount()
Statistics
getCollectionRecreateCount in interface StatisticsStatistics.getCollectionRecreateCount()public long getStartTime()
getStartTime in interface StatisticsSystem.currentTimeMillis())Statistics.getStartTime()public boolean isStatisticsEnabled()
Statistics
isStatisticsEnabled in interface StatisticsStatistics.isStatisticsEnabled()public void setStatisticsEnabled(boolean enable)
Statistics
setStatisticsEnabled in interface StatisticsStatistics.setStatisticsEnabled(boolean)public void logSummary()
Statistics
logSummary in interface Statisticspublic String[] getCollectionRoleNames()
Statistics
getCollectionRoleNames in interface Statisticspublic String[] getEntityNames()
Statistics
getEntityNames in interface Statisticspublic String[] getQueries()
Statistics
getQueries in interface Statisticspublic String[] getSecondLevelCacheRegionNames()
Statistics
getSecondLevelCacheRegionNames in interface Statisticspublic long getSuccessfulTransactionCount()
Statistics
getSuccessfulTransactionCount in interface Statisticspublic long getTransactionCount()
Statistics
getTransactionCount in interface Statisticspublic long getCloseStatementCount()
Statistics
getCloseStatementCount in interface Statisticspublic long getPrepareStatementCount()
Statistics
getPrepareStatementCount in interface Statisticspublic long getOptimisticFailureCount()
Statistics
getOptimisticFailureCount in interface Statisticspublic String getQueryExecutionMaxTimeQueryString()
Statistics
getQueryExecutionMaxTimeQueryString in interface Statistics
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||