Package org.hibernate.stat
Class ConcurrentStatisticsImpl
java.lang.Object
org.hibernate.stat.ConcurrentStatisticsImpl
- All Implemented Interfaces:
Statistics,StatisticsImplementor
Implementation of
Statistics, as well as StatisticsImplementor, based on the
java.util.concurrent package introduced in Java 5.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()reset all statisticsvoidCallback about a session being closed.voidCallback about a statement being closed.voidconnect()Callback about a connection being obtained fromConnectionProvidervoiddeleteEntity(String entityName) Callback about an entity being deleted.voidendTransaction(boolean success) Callback about a transaction completing.voidfetchCollection(String role) Callback to indicate a collection being fetched.voidfetchEntity(String entityName) Callback about an entity being fetched.voidflush()Callback about a flush occurringlongThe 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 queryString) 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 completedvoidinsertEntity(String entityName) Callback about an entity being insertedbooleanAre statistics loggedvoidloadCollection(String role) Callback about a collection loading.voidloadEntity(String entityName) Callback about an entity being loaded.voidlog in info level the main statisticsvoidCallback about a session being opened.voidoptimisticFailure(String entityName) Callback about an optimistic lock failure on an entityvoidCallback about a statement being prepared.voidqueryCacheHit(String hql, String regionName) Callback indicating a get from the query cache resulted in a hit.voidqueryCacheMiss(String hql, String regionName) Callback indicating a get from the query cache resulted in a miss.voidqueryCachePut(String hql, String regionName) Callback indicating a put into the query cache.voidqueryExecuted(String hql, int rows, long time) Callback indicating execution of a sql/hql queryvoidrecreateCollection(String role) Callback indicating a collection recreation (full deletion + full (re-)insertion).voidremoveCollection(String role) Callback indicating a collection removal.voidsecondLevelCacheHit(String regionName) Callback indicating a get from second level cache resulted in a hit.voidsecondLevelCacheMiss(String regionName) Callback indicating a get from second level cache resulted in a miss.voidsecondLevelCachePut(String regionName) Callback indicating a put into second level cache.voidsetStatisticsEnabled(boolean b) Enable statistics logs (this is a dynamic parameter)toString()voidupdateCollection(String role) Callback indicating a collection was updated.voidupdateEntity(String entityName) Callback about an entity being updated.
-
Constructor Details
-
ConcurrentStatisticsImpl
public ConcurrentStatisticsImpl() -
ConcurrentStatisticsImpl
-
-
Method Details
-
clear
public void clear()reset all statistics- Specified by:
clearin interfaceStatistics
-
openSession
public void openSession()Description copied from interface:StatisticsImplementorCallback about a session being opened.- Specified by:
openSessionin interfaceStatisticsImplementor
-
closeSession
public void closeSession()Description copied from interface:StatisticsImplementorCallback about a session being closed.- Specified by:
closeSessionin interfaceStatisticsImplementor
-
flush
public void flush()Description copied from interface:StatisticsImplementorCallback about a flush occurring- Specified by:
flushin interfaceStatisticsImplementor
-
connect
public void connect()Description copied from interface:StatisticsImplementorCallback about a connection being obtained fromConnectionProvider- Specified by:
connectin interfaceStatisticsImplementor
-
loadEntity
Description copied from interface:StatisticsImplementorCallback about an entity being loaded. This might indicate a proxy or a fully initialized entity, but in either case it means without a separate SQL query being needed.- Specified by:
loadEntityin interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity loaded.
-
fetchEntity
Description copied from interface:StatisticsImplementorCallback about an entity being fetched. UnlikeStatisticsImplementor.loadEntity(java.lang.String)this indicates a separate query being performed.- Specified by:
fetchEntityin interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity fetched.
-
getEntityStatistics
find entity statistics per name- Specified by:
getEntityStatisticsin interfaceStatistics- Parameters:
entityName- entity name- Returns:
- EntityStatistics object
-
updateEntity
Description copied from interface:StatisticsImplementorCallback about an entity being updated.- Specified by:
updateEntityin interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity updated.
-
insertEntity
Description copied from interface:StatisticsImplementorCallback about an entity being inserted- Specified by:
insertEntityin interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity inserted
-
deleteEntity
Description copied from interface:StatisticsImplementorCallback about an entity being deleted.- Specified by:
deleteEntityin interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity deleted.
-
getCollectionStatistics
Get collection statistics per role- Specified by:
getCollectionStatisticsin interfaceStatistics- Parameters:
role- collection role- Returns:
- CollectionStatistics
-
loadCollection
Description copied from interface:StatisticsImplementorCallback about a collection loading. This might indicate a lazy collection or an initialized collection being created, but in either case it means without a separate SQL query being needed.- Specified by:
loadCollectionin interfaceStatisticsImplementor- Parameters:
role- The collection role.
-
fetchCollection
Description copied from interface:StatisticsImplementorCallback to indicate a collection being fetched. UnlikeStatisticsImplementor.loadCollection(java.lang.String), this indicates a separate query was needed.- Specified by:
fetchCollectionin interfaceStatisticsImplementor- Parameters:
role- The collection role.
-
updateCollection
Description copied from interface:StatisticsImplementorCallback indicating a collection was updated.- Specified by:
updateCollectionin interfaceStatisticsImplementor- Parameters:
role- The collection role.
-
recreateCollection
Description copied from interface:StatisticsImplementorCallback indicating a collection recreation (full deletion + full (re-)insertion).- Specified by:
recreateCollectionin interfaceStatisticsImplementor- Parameters:
role- The collection role.
-
removeCollection
Description copied from interface:StatisticsImplementorCallback indicating a collection removal.- Specified by:
removeCollectionin interfaceStatisticsImplementor- Parameters:
role- The collection role.
-
getSecondLevelCacheStatistics
Second level cache statistics per region- Specified by:
getSecondLevelCacheStatisticsin interfaceStatistics- Parameters:
regionName- region name- Returns:
- SecondLevelCacheStatistics
-
secondLevelCachePut
Description copied from interface:StatisticsImplementorCallback indicating a put into second level cache.- Specified by:
secondLevelCachePutin interfaceStatisticsImplementor- Parameters:
regionName- The name of the cache region
-
secondLevelCacheHit
Description copied from interface:StatisticsImplementorCallback indicating a get from second level cache resulted in a hit.- Specified by:
secondLevelCacheHitin interfaceStatisticsImplementor- Parameters:
regionName- The name of the cache region
-
secondLevelCacheMiss
Description copied from interface:StatisticsImplementorCallback indicating a get from second level cache resulted in a miss.- Specified by:
secondLevelCacheMissin interfaceStatisticsImplementor- Parameters:
regionName- The name of the cache region
-
queryExecuted
Description copied from interface:StatisticsImplementorCallback indicating execution of a sql/hql query- Specified by:
queryExecutedin interfaceStatisticsImplementor- Parameters:
hql- The queryrows- Number of rows returnedtime- execution time
-
queryCacheHit
Description copied from interface:StatisticsImplementorCallback indicating a get from the query cache resulted in a hit.- Specified by:
queryCacheHitin interfaceStatisticsImplementor- Parameters:
hql- The queryregionName- The name of the cache region
-
queryCacheMiss
Description copied from interface:StatisticsImplementorCallback indicating a get from the query cache resulted in a miss.- Specified by:
queryCacheMissin interfaceStatisticsImplementor- Parameters:
hql- The queryregionName- The name of the cache region
-
queryCachePut
Description copied from interface:StatisticsImplementorCallback indicating a put into the query cache.- Specified by:
queryCachePutin interfaceStatisticsImplementor- Parameters:
hql- The queryregionName- The cache region
-
getQueryStatistics
Query statistics from query string (HQL or SQL)- Specified by:
getQueryStatisticsin interfaceStatistics- Parameters:
queryString- query string- Returns:
- QueryStatistics
-
getEntityDeleteCount
public long getEntityDeleteCount()Description copied from interface:StatisticsGet global number of entity deletes- Specified by:
getEntityDeleteCountin interfaceStatistics- Returns:
- entity deletion count
-
getEntityInsertCount
public long getEntityInsertCount()Description copied from interface:StatisticsGet global number of entity inserts- Specified by:
getEntityInsertCountin interfaceStatistics- Returns:
- entity insertion count
-
getEntityLoadCount
public long getEntityLoadCount()Description copied from interface:StatisticsGet global number of entity loads- Specified by:
getEntityLoadCountin interfaceStatistics- Returns:
- entity load (from DB)
-
getEntityFetchCount
public long getEntityFetchCount()Description copied from interface:StatisticsGet global number of entity fetchs- Specified by:
getEntityFetchCountin interfaceStatistics- Returns:
- entity fetch (from DB)
-
getEntityUpdateCount
public long getEntityUpdateCount()Description copied from interface:StatisticsGet global number of entity updates- Specified by:
getEntityUpdateCountin interfaceStatistics- Returns:
- entity update
-
getQueryExecutionCount
public long getQueryExecutionCount()Description copied from interface:StatisticsGet global number of executed queries- Specified by:
getQueryExecutionCountin interfaceStatistics- Returns:
- query execution count
-
getQueryCacheHitCount
public long getQueryCacheHitCount()Description copied from interface:StatisticsGet the global number of cached queries successfully retrieved from cache- Specified by:
getQueryCacheHitCountin 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- Returns:
- flush
-
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- Returns:
- session connect
-
getSecondLevelCacheHitCount
public long getSecondLevelCacheHitCount()Description copied from interface:StatisticsGlobal number of cacheable entities/collections successfully retrieved from the cache- Specified by:
getSecondLevelCacheHitCountin interfaceStatistics- Returns:
- second level cache hit
-
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- Returns:
- second level cache miss
-
getSecondLevelCachePutCount
public long getSecondLevelCachePutCount()Description copied from interface:StatisticsGlobal number of cacheable entities/collections put in the cache- Specified by:
getSecondLevelCachePutCountin interfaceStatistics- Returns:
- second level cache put
-
getSessionCloseCount
public long getSessionCloseCount()Description copied from interface:StatisticsGlobal number of sessions closed- Specified by:
getSessionCloseCountin interfaceStatistics- Returns:
- session closing
-
getSessionOpenCount
public long getSessionOpenCount()Description copied from interface:StatisticsGlobal number of sessions opened- Specified by:
getSessionOpenCountin interfaceStatistics- Returns:
- session opening
-
getCollectionLoadCount
public long getCollectionLoadCount()Description copied from interface:StatisticsGlobal number of collections loaded- Specified by:
getCollectionLoadCountin interfaceStatistics- Returns:
- collection loading (from DB)
-
getCollectionFetchCount
public long getCollectionFetchCount()Description copied from interface:StatisticsGlobal number of collections fetched- Specified by:
getCollectionFetchCountin interfaceStatistics- Returns:
- collection fetching (from DB)
-
getCollectionUpdateCount
public long getCollectionUpdateCount()Description copied from interface:StatisticsGlobal number of collections updated- Specified by:
getCollectionUpdateCountin interfaceStatistics- Returns:
- collection update
-
getCollectionRemoveCount
public long getCollectionRemoveCount()Description copied from interface:StatisticsGlobal number of collections removed- Specified by:
getCollectionRemoveCountin interfaceStatistics- Returns:
- collection removal FIXME: even if isInverse="true"?
-
getCollectionRecreateCount
public long getCollectionRecreateCount()Description copied from interface:StatisticsGlobal number of collections recreated- Specified by:
getCollectionRecreateCountin interfaceStatistics- Returns:
- collection recreation
-
getStartTime
public long getStartTime()- Specified by:
getStartTimein interfaceStatistics- Returns:
- start time in ms (JVM standards
System.currentTimeMillis())
-
logSummary
public void logSummary()log in info level the main statistics- Specified by:
logSummaryin interfaceStatistics
-
isStatisticsEnabled
public boolean isStatisticsEnabled()Are statistics logged- Specified by:
isStatisticsEnabledin interfaceStatistics
-
setStatisticsEnabled
public void setStatisticsEnabled(boolean b) Enable statistics logs (this is a dynamic parameter)- Specified by:
setStatisticsEnabledin interfaceStatistics
-
getQueryExecutionMaxTime
public long getQueryExecutionMaxTime()Description copied from interface:StatisticsGet the time in milliseconds of the slowest query.- Specified by:
getQueryExecutionMaxTimein interfaceStatistics- Returns:
- Returns the max query execution time, for all queries
-
getQueries
Get all executed query strings- Specified by:
getQueriesin interfaceStatistics
-
getEntityNames
Get the names of all entities- Specified by:
getEntityNamesin interfaceStatistics
-
getCollectionRoleNames
Get the names of all collection roles- Specified by:
getCollectionRoleNamesin interfaceStatistics
-
getSecondLevelCacheRegionNames
Get all second-level cache region names- Specified by:
getSecondLevelCacheRegionNamesin interfaceStatistics
-
endTransaction
public void endTransaction(boolean success) Description copied from interface:StatisticsImplementorCallback about a transaction completing.- Specified by:
endTransactionin interfaceStatisticsImplementor- Parameters:
success- Was the transaction successful?
-
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
-
closeStatement
public void closeStatement()Description copied from interface:StatisticsImplementorCallback about a statement being closed.- Specified by:
closeStatementin interfaceStatisticsImplementor
-
prepareStatement
public void prepareStatement()Description copied from interface:StatisticsImplementorCallback about a statement being prepared.- Specified by:
prepareStatementin interfaceStatisticsImplementor
-
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
-
optimisticFailure
Description copied from interface:StatisticsImplementorCallback about an optimistic lock failure on an entity- Specified by:
optimisticFailurein interfaceStatisticsImplementor- Parameters:
entityName- The name of the entity.
-
getOptimisticFailureCount
public long getOptimisticFailureCount()Description copied from interface:StatisticsThe number of StaleObjectStateExceptions that occurred- Specified by:
getOptimisticFailureCountin interfaceStatistics
-
toString
-
getQueryExecutionMaxTimeQueryString
Description copied from interface:StatisticsGet the query string for the slowest query.- Specified by:
getQueryExecutionMaxTimeQueryStringin interfaceStatistics
-