Methods Summary |
---|
public synchronized void | clear()reset all statistics
secondLevelCacheHitCount = 0;
secondLevelCacheMissCount = 0;
secondLevelCachePutCount = 0;
sessionCloseCount = 0;
sessionOpenCount = 0;
flushCount = 0;
connectCount = 0;
prepareStatementCount = 0;
closeStatementCount = 0;
entityDeleteCount = 0;
entityInsertCount = 0;
entityUpdateCount = 0;
entityLoadCount = 0;
entityFetchCount = 0;
collectionRemoveCount = 0;
collectionUpdateCount = 0;
collectionRecreateCount = 0;
collectionLoadCount = 0;
collectionFetchCount = 0;
queryExecutionCount = 0;
queryCacheHitCount = 0;
queryExecutionMaxTime = 0;
queryExecutionMaxTimeQueryString = null;
queryCacheMissCount = 0;
queryCachePutCount = 0;
transactionCount = 0;
commitedTransactionCount = 0;
optimisticFailureCount = 0;
secondLevelCacheStatistics.clear();
entityStatistics.clear();
collectionStatistics.clear();
queryStatistics.clear();
startTime = System.currentTimeMillis();
|
public synchronized void | closeSession()
sessionCloseCount++;
|
public void | closeStatement()
closeStatementCount++;
|
public synchronized void | connect()
connectCount++;
|
public synchronized void | deleteEntity(java.lang.String entityName)
entityDeleteCount++;
EntityStatistics es = getEntityStatistics(entityName);
es.deleteCount++;
|
public void | endTransaction(boolean success)
transactionCount++;
if (success) commitedTransactionCount++;
|
public synchronized void | fetchCollection(java.lang.String role)
collectionFetchCount++;
getCollectionStatistics(role).fetchCount++;
|
public synchronized void | fetchEntity(java.lang.String entityName)
entityFetchCount++;
getEntityStatistics(entityName).fetchCount++;
|
public synchronized void | flush()
flushCount++;
|
public long | getCloseStatementCount()
return closeStatementCount;
|
public long | getCollectionFetchCount()
return collectionFetchCount;
|
public long | getCollectionLoadCount()
return collectionLoadCount;
|
public long | getCollectionRecreateCount()
return collectionRecreateCount;
|
public long | getCollectionRemoveCount()
return collectionRemoveCount;
|
public java.lang.String[] | getCollectionRoleNames()Get the names of all collection roles
if (sessionFactory==null) {
return ArrayHelper.toStringArray( collectionStatistics.keySet() );
}
else {
return ArrayHelper.toStringArray( sessionFactory.getAllCollectionMetadata().keySet() );
}
|
public synchronized CollectionStatistics | getCollectionStatistics(java.lang.String role)Get collection statistics per role
CollectionStatistics cs = (CollectionStatistics) collectionStatistics.get(role);
if (cs==null) {
cs = new CollectionStatistics(role);
collectionStatistics.put(role, cs);
}
return cs;
|
public long | getCollectionUpdateCount()
return collectionUpdateCount;
|
public long | getConnectCount()
return connectCount;
|
public long | getEntityDeleteCount()
return entityDeleteCount;
|
public long | getEntityFetchCount()
return entityFetchCount;
|
public long | getEntityInsertCount()
return entityInsertCount;
|
public long | getEntityLoadCount()
return entityLoadCount;
|
public java.lang.String[] | getEntityNames()Get the names of all entities
if (sessionFactory==null) {
return ArrayHelper.toStringArray( entityStatistics.keySet() );
}
else {
return ArrayHelper.toStringArray( sessionFactory.getAllClassMetadata().keySet() );
}
|
public synchronized EntityStatistics | getEntityStatistics(java.lang.String entityName)find entity statistics per name
EntityStatistics es = (EntityStatistics) entityStatistics.get(entityName);
if (es==null) {
es = new EntityStatistics(entityName);
entityStatistics.put(entityName, es);
}
return es;
|
public long | getEntityUpdateCount()
return entityUpdateCount;
|
public long | getFlushCount()
return flushCount;
|
public long | getOptimisticFailureCount()
return optimisticFailureCount;
|
public long | getPrepareStatementCount()
return prepareStatementCount;
|
public java.lang.String[] | getQueries()Get all executed query strings
return ArrayHelper.toStringArray( queryStatistics.keySet() );
|
public long | getQueryCacheHitCount()
return queryCacheHitCount;
|
public long | getQueryCacheMissCount()
return queryCacheMissCount;
|
public long | getQueryCachePutCount()
return queryCachePutCount;
|
public long | getQueryExecutionCount()
return queryExecutionCount;
|
public long | getQueryExecutionMaxTime()
return queryExecutionMaxTime;
|
public java.lang.String | getQueryExecutionMaxTimeQueryString()
return queryExecutionMaxTimeQueryString;
|
public synchronized QueryStatistics | getQueryStatistics(java.lang.String queryString)Query statistics from query string (HQL or SQL)
QueryStatistics qs = (QueryStatistics) queryStatistics.get(queryString);
if (qs==null) {
qs = new QueryStatistics(queryString);
queryStatistics.put(queryString, qs);
}
return qs;
|
public long | getSecondLevelCacheHitCount()
return secondLevelCacheHitCount;
|
public long | getSecondLevelCacheMissCount()
return secondLevelCacheMissCount;
|
public long | getSecondLevelCachePutCount()
return secondLevelCachePutCount;
|
public java.lang.String[] | getSecondLevelCacheRegionNames()Get all second-level cache region names
if (sessionFactory==null) {
return ArrayHelper.toStringArray( secondLevelCacheStatistics.keySet() );
}
else {
return ArrayHelper.toStringArray( sessionFactory.getAllSecondLevelCacheRegions().keySet() );
}
|
public synchronized SecondLevelCacheStatistics | getSecondLevelCacheStatistics(java.lang.String regionName)Second level cache statistics per region
SecondLevelCacheStatistics slcs = (SecondLevelCacheStatistics) secondLevelCacheStatistics.get(regionName);
if (slcs==null) {
if (sessionFactory == null) return null;
Cache cache = sessionFactory.getSecondLevelCacheRegion(regionName);
if (cache==null) return null;
slcs = new SecondLevelCacheStatistics(cache);
secondLevelCacheStatistics.put(regionName, slcs);
}
return slcs;
|
public long | getSessionCloseCount()
return sessionCloseCount;
|
public long | getSessionOpenCount()
return sessionOpenCount;
|
public long | getStartTime()
return startTime;
|
public long | getSuccessfulTransactionCount()
return commitedTransactionCount;
|
public long | getTransactionCount()
return transactionCount;
|
public synchronized void | insertEntity(java.lang.String entityName)
entityInsertCount++;
EntityStatistics es = getEntityStatistics(entityName);
es.insertCount++;
|
public boolean | isStatisticsEnabled()Are statistics logged
return isStatisticsEnabled;
|
public synchronized void | loadCollection(java.lang.String role)
collectionLoadCount++;
getCollectionStatistics(role).loadCount++;
|
public synchronized void | loadEntity(java.lang.String entityName)
entityLoadCount++;
getEntityStatistics(entityName).loadCount++;
|
public void | logSummary()log in info level the main statistics
log.info("Logging statistics....");
log.info("start time: " + startTime);
log.info("sessions opened: " + sessionOpenCount);
log.info("sessions closed: " + sessionCloseCount);
log.info("transactions: " + transactionCount);
log.info("successful transactions: " + commitedTransactionCount);
log.info("optimistic lock failures: " + optimisticFailureCount);
log.info("flushes: " + flushCount);
log.info("connections obtained: " + connectCount);
log.info("statements prepared: " + prepareStatementCount);
log.info("statements closed: " + closeStatementCount);
log.info("second level cache puts: " + secondLevelCachePutCount);
log.info("second level cache hits: " + secondLevelCacheHitCount);
log.info("second level cache misses: " + secondLevelCacheMissCount);
log.info("entities loaded: " + entityLoadCount);
log.info("entities updated: " + entityUpdateCount);
log.info("entities inserted: " + entityInsertCount);
log.info("entities deleted: " + entityDeleteCount);
log.info("entities fetched (minimize this): " + entityFetchCount);
log.info("collections loaded: " + collectionLoadCount);
log.info("collections updated: " + collectionUpdateCount);
log.info("collections removed: " + collectionRemoveCount);
log.info("collections recreated: " + collectionRecreateCount);
log.info("collections fetched (minimize this): " + collectionFetchCount);
log.info("queries executed to database: " + queryExecutionCount);
log.info("query cache puts: " + queryCachePutCount);
log.info("query cache hits: " + queryCacheHitCount);
log.info("query cache misses: " + queryCacheMissCount);
log.info("max query time: " + queryExecutionMaxTime + "ms");
|
public synchronized void | openSession()
sessionOpenCount++;
|
public void | optimisticFailure(java.lang.String entityName)
optimisticFailureCount++;
getEntityStatistics(entityName).optimisticFailureCount++;
|
public void | prepareStatement()
prepareStatementCount++;
|
public synchronized void | queryCacheHit(java.lang.String hql, java.lang.String regionName)
queryCacheHitCount++;
if (hql!=null) {
QueryStatistics qs = getQueryStatistics(hql);
qs.cacheHitCount++;
}
SecondLevelCacheStatistics slcs = getSecondLevelCacheStatistics(regionName);
slcs.hitCount++;
|
public synchronized void | queryCacheMiss(java.lang.String hql, java.lang.String regionName)
queryCacheMissCount++;
if (hql!=null) {
QueryStatistics qs = getQueryStatistics(hql);
qs.cacheMissCount++;
}
SecondLevelCacheStatistics slcs = getSecondLevelCacheStatistics(regionName);
slcs.missCount++;
|
public synchronized void | queryCachePut(java.lang.String hql, java.lang.String regionName)
queryCachePutCount++;
if (hql!=null) {
QueryStatistics qs = getQueryStatistics(hql);
qs.cachePutCount++;
}
SecondLevelCacheStatistics slcs = getSecondLevelCacheStatistics(regionName);
slcs.putCount++;
|
public synchronized void | queryExecuted(java.lang.String hql, int rows, long time)
queryExecutionCount++;
if (queryExecutionMaxTime<time) {
queryExecutionMaxTime=time;
queryExecutionMaxTimeQueryString = hql;
}
if (hql!=null) {
QueryStatistics qs = getQueryStatistics(hql);
qs.executed(rows, time);
}
|
public synchronized void | recreateCollection(java.lang.String role)
collectionRecreateCount++;
getCollectionStatistics(role).recreateCount++;
|
public synchronized void | removeCollection(java.lang.String role)
collectionRemoveCount++;
getCollectionStatistics(role).removeCount++;
|
public synchronized void | secondLevelCacheHit(java.lang.String regionName)
secondLevelCacheHitCount++;
getSecondLevelCacheStatistics(regionName).hitCount++;
|
public synchronized void | secondLevelCacheMiss(java.lang.String regionName)
secondLevelCacheMissCount++;
getSecondLevelCacheStatistics(regionName).missCount++;
|
public synchronized void | secondLevelCachePut(java.lang.String regionName)
secondLevelCachePutCount++;
getSecondLevelCacheStatistics(regionName).putCount++;
|
public void | setStatisticsEnabled(boolean b)Enable statistics logs (this is a dynamic parameter)
isStatisticsEnabled = b;
|
public java.lang.String | toString()
return new StringBuffer()
.append("Statistics[")
.append("start time=").append(startTime)
.append(",sessions opened=").append(sessionOpenCount)
.append(",sessions closed=").append(sessionCloseCount)
.append(",transactions=").append(transactionCount)
.append(",successful transactions=").append(commitedTransactionCount)
.append(",optimistic lock failures=").append(optimisticFailureCount)
.append(",flushes=").append(flushCount)
.append(",connections obtained=").append(connectCount)
.append(",statements prepared=").append(prepareStatementCount)
.append(",statements closed=").append(closeStatementCount)
.append(",second level cache puts=").append(secondLevelCachePutCount)
.append(",second level cache hits=").append(secondLevelCacheHitCount)
.append(",second level cache misses=").append(secondLevelCacheMissCount)
.append(",entities loaded=").append(entityLoadCount)
.append(",entities updated=").append(entityUpdateCount)
.append(",entities inserted=").append(entityInsertCount)
.append(",entities deleted=").append(entityDeleteCount)
.append(",entities fetched=").append(entityFetchCount)
.append(",collections loaded=").append(collectionLoadCount)
.append(",collections updated=").append(collectionUpdateCount)
.append(",collections removed=").append(collectionRemoveCount)
.append(",collections recreated=").append(collectionRecreateCount)
.append(",collections fetched=").append(collectionFetchCount)
.append(",queries executed to database=").append(queryExecutionCount)
.append(",query cache puts=").append(queryCachePutCount)
.append(",query cache hits=").append(queryCacheHitCount)
.append(",query cache misses=").append(queryCacheMissCount)
.append(",max query time=").append(queryExecutionMaxTime)
.append(']")
.toString();
|
public synchronized void | updateCollection(java.lang.String role)
collectionUpdateCount++;
getCollectionStatistics(role).updateCount++;
|
public synchronized void | updateEntity(java.lang.String entityName)
entityUpdateCount++;
EntityStatistics es = getEntityStatistics(entityName);
es.updateCount++;
|