org.hibernate.stat
Class ConcurrentStatisticsImpl

java.lang.Object
  extended by org.hibernate.stat.ConcurrentStatisticsImpl
All Implemented Interfaces:
Statistics, StatisticsImplementor

public class ConcurrentStatisticsImpl
extends Object
implements Statistics, StatisticsImplementor

Implementation of Statistics, as well as StatisticsImplementor, based on the java.util.concurrent package introduced in Java 5.

Author:
Alex Snaps

Constructor Summary
ConcurrentStatisticsImpl()
           
ConcurrentStatisticsImpl(SessionFactoryImplementor sessionFactory)
           
 
Method Summary
 void clear()
          reset all statistics
 void closeSession()
           
 void closeStatement()
           
 void connect()
           
 void deleteEntity(String entityName)
           
 void endTransaction(boolean success)
           
 void fetchCollection(String role)
           
 void fetchEntity(String entityName)
           
 void flush()
           
 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 queryString)
          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
 void insertEntity(String entityName)
           
 boolean isStatisticsEnabled()
          Are statistics logged
 void loadCollection(String role)
           
 void loadEntity(String entityName)
           
 void logSummary()
          log in info level the main statistics
 void openSession()
           
 void optimisticFailure(String entityName)
           
 void prepareStatement()
           
 void queryCacheHit(String hql, String regionName)
           
 void queryCacheMiss(String hql, String regionName)
           
 void queryCachePut(String hql, String regionName)
           
 void queryExecuted(String hql, int rows, long time)
           
 void recreateCollection(String role)
           
 void removeCollection(String role)
           
 void secondLevelCacheHit(String regionName)
           
 void secondLevelCacheMiss(String regionName)
           
 void secondLevelCachePut(String regionName)
           
 void setStatisticsEnabled(boolean b)
          Enable statistics logs (this is a dynamic parameter)
 String toString()
           
 void updateCollection(String role)
           
 void updateEntity(String entityName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcurrentStatisticsImpl

public ConcurrentStatisticsImpl()

ConcurrentStatisticsImpl

public ConcurrentStatisticsImpl(SessionFactoryImplementor sessionFactory)
Method Detail

clear

public void clear()
reset all statistics

Specified by:
clear in interface Statistics

openSession

public void openSession()
Specified by:
openSession in interface StatisticsImplementor

closeSession

public void closeSession()
Specified by:
closeSession in interface StatisticsImplementor

flush

public void flush()
Specified by:
flush in interface StatisticsImplementor

connect

public void connect()
Specified by:
connect in interface StatisticsImplementor

loadEntity

public void loadEntity(String entityName)
Specified by:
loadEntity in interface StatisticsImplementor

fetchEntity

public void fetchEntity(String entityName)
Specified by:
fetchEntity in interface StatisticsImplementor

getEntityStatistics

public EntityStatistics getEntityStatistics(String entityName)
find entity statistics per name

Specified by:
getEntityStatistics in interface Statistics
Parameters:
entityName - entity name
Returns:
EntityStatistics object

updateEntity

public void updateEntity(String entityName)
Specified by:
updateEntity in interface StatisticsImplementor

insertEntity

public void insertEntity(String entityName)
Specified by:
insertEntity in interface StatisticsImplementor

deleteEntity

public void deleteEntity(String entityName)
Specified by:
deleteEntity in interface StatisticsImplementor

getCollectionStatistics

public CollectionStatistics getCollectionStatistics(String role)
Get collection statistics per role

Specified by:
getCollectionStatistics in interface Statistics
Parameters:
role - collection role
Returns:
CollectionStatistics

loadCollection

public void loadCollection(String role)
Specified by:
loadCollection in interface StatisticsImplementor

fetchCollection

public void fetchCollection(String role)
Specified by:
fetchCollection in interface StatisticsImplementor

updateCollection

public void updateCollection(String role)
Specified by:
updateCollection in interface StatisticsImplementor

recreateCollection

public void recreateCollection(String role)
Specified by:
recreateCollection in interface StatisticsImplementor

removeCollection

public void removeCollection(String role)
Specified by:
removeCollection in interface StatisticsImplementor

getSecondLevelCacheStatistics

public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName)
Second level cache statistics per region

Specified by:
getSecondLevelCacheStatistics in interface Statistics
Parameters:
regionName - region name
Returns:
SecondLevelCacheStatistics

secondLevelCachePut

public void secondLevelCachePut(String regionName)
Specified by:
secondLevelCachePut in interface StatisticsImplementor

secondLevelCacheHit

public void secondLevelCacheHit(String regionName)
Specified by:
secondLevelCacheHit in interface StatisticsImplementor

secondLevelCacheMiss

public void secondLevelCacheMiss(String regionName)
Specified by:
secondLevelCacheMiss in interface StatisticsImplementor

queryExecuted

public void queryExecuted(String hql,
                          int rows,
                          long time)
Specified by:
queryExecuted in interface StatisticsImplementor

queryCacheHit

public void queryCacheHit(String hql,
                          String regionName)
Specified by:
queryCacheHit in interface StatisticsImplementor

queryCacheMiss

public void queryCacheMiss(String hql,
                           String regionName)
Specified by:
queryCacheMiss in interface StatisticsImplementor

queryCachePut

public void queryCachePut(String hql,
                          String regionName)
Specified by:
queryCachePut in interface StatisticsImplementor

getQueryStatistics

public QueryStatistics getQueryStatistics(String queryString)
Query statistics from query string (HQL or SQL)

Specified by:
getQueryStatistics in interface Statistics
Parameters:
queryString - query string
Returns:
QueryStatistics

getEntityDeleteCount

public long getEntityDeleteCount()
Description copied from interface: Statistics
Get global number of entity deletes

Specified by:
getEntityDeleteCount in interface Statistics
Returns:
entity deletion count

getEntityInsertCount

public long getEntityInsertCount()
Description copied from interface: Statistics
Get global number of entity inserts

Specified by:
getEntityInsertCount in interface Statistics
Returns:
entity insertion count

getEntityLoadCount

public long getEntityLoadCount()
Description copied from interface: Statistics
Get global number of entity loads

Specified by:
getEntityLoadCount in interface Statistics
Returns:
entity load (from DB)

getEntityFetchCount

public long getEntityFetchCount()
Description copied from interface: Statistics
Get global number of entity fetchs

Specified by:
getEntityFetchCount in interface Statistics
Returns:
entity fetch (from DB)

getEntityUpdateCount

public long getEntityUpdateCount()
Description copied from interface: Statistics
Get global number of entity updates

Specified by:
getEntityUpdateCount in interface Statistics
Returns:
entity update

getQueryExecutionCount

public long getQueryExecutionCount()
Description copied from interface: Statistics
Get global number of executed queries

Specified by:
getQueryExecutionCount in interface Statistics
Returns:
query execution count

getQueryCacheHitCount

public long getQueryCacheHitCount()
Description copied from interface: Statistics
Get the global number of cached queries successfully retrieved from cache

Specified by:
getQueryCacheHitCount in interface Statistics

getQueryCacheMissCount

public long getQueryCacheMissCount()
Description copied from interface: Statistics
Get the global number of cached queries *not* found in cache

Specified by:
getQueryCacheMissCount in interface Statistics

getQueryCachePutCount

public long getQueryCachePutCount()
Description copied from interface: Statistics
Get the global number of cacheable queries put in cache

Specified by:
getQueryCachePutCount in interface Statistics

getFlushCount

public long getFlushCount()
Description copied from interface: Statistics
Get the global number of flush executed by sessions (either implicit or explicit)

Specified by:
getFlushCount in interface Statistics
Returns:
flush

getConnectCount

public long getConnectCount()
Description copied from interface: Statistics
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)

Specified by:
getConnectCount in interface Statistics
Returns:
session connect

getSecondLevelCacheHitCount

public long getSecondLevelCacheHitCount()
Description copied from interface: Statistics
Global number of cacheable entities/collections successfully retrieved from the cache

Specified by:
getSecondLevelCacheHitCount in interface Statistics
Returns:
second level cache hit

getSecondLevelCacheMissCount

public long getSecondLevelCacheMissCount()
Description copied from interface: Statistics
Global number of cacheable entities/collections not found in the cache and loaded from the database.

Specified by:
getSecondLevelCacheMissCount in interface Statistics
Returns:
second level cache miss

getSecondLevelCachePutCount

public long getSecondLevelCachePutCount()
Description copied from interface: Statistics
Global number of cacheable entities/collections put in the cache

Specified by:
getSecondLevelCachePutCount in interface Statistics
Returns:
second level cache put

getSessionCloseCount

public long getSessionCloseCount()
Description copied from interface: Statistics
Global number of sessions closed

Specified by:
getSessionCloseCount in interface Statistics
Returns:
session closing

getSessionOpenCount

public long getSessionOpenCount()
Description copied from interface: Statistics
Global number of sessions opened

Specified by:
getSessionOpenCount in interface Statistics
Returns:
session opening

getCollectionLoadCount

public long getCollectionLoadCount()
Description copied from interface: Statistics
Global number of collections loaded

Specified by:
getCollectionLoadCount in interface Statistics
Returns:
collection loading (from DB)

getCollectionFetchCount

public long getCollectionFetchCount()
Description copied from interface: Statistics
Global number of collections fetched

Specified by:
getCollectionFetchCount in interface Statistics
Returns:
collection fetching (from DB)

getCollectionUpdateCount

public long getCollectionUpdateCount()
Description copied from interface: Statistics
Global number of collections updated

Specified by:
getCollectionUpdateCount in interface Statistics
Returns:
collection update

getCollectionRemoveCount

public long getCollectionRemoveCount()
Description copied from interface: Statistics
Global number of collections removed

Specified by:
getCollectionRemoveCount in interface Statistics
Returns:
collection removal FIXME: even if isInverse="true"?

getCollectionRecreateCount

public long getCollectionRecreateCount()
Description copied from interface: Statistics
Global number of collections recreated

Specified by:
getCollectionRecreateCount in interface Statistics
Returns:
collection recreation

getStartTime

public long getStartTime()
Specified by:
getStartTime in interface Statistics
Returns:
start time in ms (JVM standards System.currentTimeMillis())

logSummary

public void logSummary()
log in info level the main statistics

Specified by:
logSummary in interface Statistics

isStatisticsEnabled

public boolean isStatisticsEnabled()
Are statistics logged

Specified by:
isStatisticsEnabled in interface Statistics

setStatisticsEnabled

public void setStatisticsEnabled(boolean b)
Enable statistics logs (this is a dynamic parameter)

Specified by:
setStatisticsEnabled in interface Statistics

getQueryExecutionMaxTime

public long getQueryExecutionMaxTime()
Description copied from interface: Statistics
Get the time in milliseconds of the slowest query.

Specified by:
getQueryExecutionMaxTime in interface Statistics
Returns:
Returns the max query execution time, for all queries

getQueries

public String[] getQueries()
Get all executed query strings

Specified by:
getQueries in interface Statistics

getEntityNames

public String[] getEntityNames()
Get the names of all entities

Specified by:
getEntityNames in interface Statistics

getCollectionRoleNames

public String[] getCollectionRoleNames()
Get the names of all collection roles

Specified by:
getCollectionRoleNames in interface Statistics

getSecondLevelCacheRegionNames

public String[] getSecondLevelCacheRegionNames()
Get all second-level cache region names

Specified by:
getSecondLevelCacheRegionNames in interface Statistics

endTransaction

public void endTransaction(boolean success)
Specified by:
endTransaction in interface StatisticsImplementor

getSuccessfulTransactionCount

public long getSuccessfulTransactionCount()
Description copied from interface: Statistics
The number of transactions we know to have been successful

Specified by:
getSuccessfulTransactionCount in interface Statistics

getTransactionCount

public long getTransactionCount()
Description copied from interface: Statistics
The number of transactions we know to have completed

Specified by:
getTransactionCount in interface Statistics

closeStatement

public void closeStatement()
Specified by:
closeStatement in interface StatisticsImplementor

prepareStatement

public void prepareStatement()
Specified by:
prepareStatement in interface StatisticsImplementor

getCloseStatementCount

public long getCloseStatementCount()
Description copied from interface: Statistics
The number of prepared statements that were released

Specified by:
getCloseStatementCount in interface Statistics

getPrepareStatementCount

public long getPrepareStatementCount()
Description copied from interface: Statistics
The number of prepared statements that were acquired

Specified by:
getPrepareStatementCount in interface Statistics

optimisticFailure

public void optimisticFailure(String entityName)
Specified by:
optimisticFailure in interface StatisticsImplementor

getOptimisticFailureCount

public long getOptimisticFailureCount()
Description copied from interface: Statistics
The number of StaleObjectStateExceptions that occurred

Specified by:
getOptimisticFailureCount in interface Statistics

toString

public String toString()
Overrides:
toString in class Object

getQueryExecutionMaxTimeQueryString

public String getQueryExecutionMaxTimeQueryString()
Description copied from interface: Statistics
Get the query string for the slowest query.

Specified by:
getQueryExecutionMaxTimeQueryString in interface Statistics


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.