use of org.hibernate.stat.Statistics in project gocd by gocd.
the class HibernateInformationProvider method asJson.
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
Statistics statistics = sessionFactory.getStatistics();
if (!statistics.isStatisticsEnabled()) {
return json;
}
json.put("EntityDeleteCount", statistics.getEntityDeleteCount());
json.put("EntityInsertCount", statistics.getEntityInsertCount());
json.put("EntityLoadCount", statistics.getEntityLoadCount());
json.put("EntityFetchCount", statistics.getEntityFetchCount());
json.put("EntityUpdateCount", statistics.getEntityUpdateCount());
json.put("QueryExecutionCount", statistics.getQueryExecutionCount());
json.put("QueryExecutionMaxTime", statistics.getQueryExecutionMaxTime());
json.put("QueryExecutionMaxTimeQueryString", statistics.getQueryExecutionMaxTimeQueryString());
json.put("QueryCacheHitCount", statistics.getQueryCacheHitCount());
json.put("QueryCacheMissCount", statistics.getQueryCacheMissCount());
json.put("QueryCachePutCount", statistics.getQueryCachePutCount());
json.put("FlushCount", statistics.getFlushCount());
json.put("ConnectCount", statistics.getConnectCount());
json.put("SecondLevelCacheHitCount", statistics.getSecondLevelCacheHitCount());
json.put("SecondLevelCacheMissCount", statistics.getSecondLevelCacheMissCount());
json.put("SecondLevelCachePutCount", statistics.getSecondLevelCachePutCount());
json.put("SessionCloseCount", statistics.getSessionCloseCount());
json.put("SessionOpenCount", statistics.getSessionOpenCount());
json.put("CollectionLoadCount", statistics.getCollectionLoadCount());
json.put("CollectionFetchCount", statistics.getCollectionFetchCount());
json.put("CollectionUpdateCount", statistics.getCollectionUpdateCount());
json.put("CollectionRemoveCount", statistics.getCollectionRemoveCount());
json.put("CollectionRecreateCount", statistics.getCollectionRecreateCount());
json.put("StartTime", statistics.getStartTime());
json.put("SecondLevelCacheRegionNames", statistics.getSecondLevelCacheRegionNames());
json.put("SuccessfulTransactionCount", statistics.getSuccessfulTransactionCount());
json.put("TransactionCount", statistics.getTransactionCount());
json.put("PrepareStatementCount", statistics.getPrepareStatementCount());
json.put("CloseStatementCount", statistics.getCloseStatementCount());
json.put("OptimisticFailureCount", statistics.getOptimisticFailureCount());
LinkedHashMap<String, Object> queryStats = new LinkedHashMap<>();
json.put("Queries", queryStats);
String[] queries = statistics.getQueries();
for (String query : queries) {
queryStats.put(query, statistics.getQueryStatistics(query));
}
LinkedHashMap<String, Object> entityStatistics = new LinkedHashMap<>();
json.put("EntityStatistics", entityStatistics);
String[] entityNames = statistics.getEntityNames();
for (String entityName : entityNames) {
entityStatistics.put(entityName, statistics.getEntityStatistics(entityName));
}
LinkedHashMap<String, Object> roleStatistics = new LinkedHashMap<>();
json.put("RoleStatistics", roleStatistics);
String[] roleNames = statistics.getCollectionRoleNames();
for (String roleName : roleNames) {
roleStatistics.put(roleName, statistics.getCollectionStatistics(roleName));
}
return json;
}
use of org.hibernate.stat.Statistics in project OpenClinica by OpenClinica.
the class RuleSetRuleDao method findByRuleSetStudyIdAndStatusAvail.
/**
* Use this method carefully as we force an eager fetch. It is also annotated with
* Transactional so it can be called from Quartz threads.
* @param studyId
* @return List of RuleSetRuleBeans
*/
@SuppressWarnings("unchecked")
@Transactional
public ArrayList<RuleSetRuleBean> findByRuleSetStudyIdAndStatusAvail(Integer studyId) {
String query = "from " + getDomainClassName() + " ruleSetRule where ruleSetRule.ruleSetBean.studyId = :studyId and status = :status ";
org.hibernate.Query q = getCurrentSession().createQuery(query);
q.setInteger("studyId", studyId);
q.setParameter("status", org.akaza.openclinica.domain.Status.AVAILABLE);
q.setCacheable(true);
q.setCacheRegion(getDomainClassName());
//JN: enabling statistics for hibernate queries etc... to monitor the performance
Statistics stats = getSessionFactory().getStatistics();
logger.info("EntityRuleSet" + stats.getEntityInsertCount());
logger.info(stats.getQueryExecutionMaxTimeQueryString());
logger.info("hit count" + stats.getSecondLevelCacheHitCount());
stats.logSummary();
ArrayList<RuleSetRuleBean> ruleSetRules = (ArrayList<RuleSetRuleBean>) q.list();
// Forcing eager fetch of actions & their properties
for (RuleSetRuleBean ruleSetRuleBean : ruleSetRules) {
for (RuleActionBean action : ruleSetRuleBean.getActions()) {
if (action instanceof RandomizeActionBean) {
((RandomizeActionBean) action).getProperties().size();
}
if (action instanceof InsertActionBean) {
((InsertActionBean) action).getProperties().size();
}
if (action instanceof ShowActionBean) {
((ShowActionBean) action).getProperties().size();
}
if (action instanceof HideActionBean) {
((HideActionBean) action).getProperties().size();
}
if (action instanceof EventActionBean) {
((EventActionBean) action).getProperties().size();
}
}
}
return ruleSetRules;
}
use of org.hibernate.stat.Statistics in project hibernate-orm by hibernate.
the class HibernateStatsImpl method getEntityStats.
@Override
public TabularData getEntityStats() {
final List<CompositeData> result = new ArrayList<CompositeData>();
final Statistics statistics = getStatistics();
for (String entity : statistics.getEntityNames()) {
final EntityStats entityStats = new EntityStats(entity, statistics.getEntityStatistics(entity));
result.add(entityStats.toCompositeData());
}
final TabularData td = EntityStats.newTabularDataInstance();
td.putAll(result.toArray(new CompositeData[result.size()]));
return td;
}
use of org.hibernate.stat.Statistics in project hibernate-orm by hibernate.
the class HibernateStatsImpl method getCollectionStats.
@Override
public TabularData getCollectionStats() {
final List<CompositeData> result = new ArrayList<CompositeData>();
final Statistics statistics = getStatistics();
for (String roleName : statistics.getCollectionRoleNames()) {
final CollectionStats collectionStats = new CollectionStats(roleName, statistics.getCollectionStatistics(roleName));
result.add(collectionStats.toCompositeData());
}
final TabularData td = CollectionStats.newTabularDataInstance();
td.putAll(result.toArray(new CompositeData[result.size()]));
return td;
}
use of org.hibernate.stat.Statistics in project hibernate-orm by hibernate.
the class EhCacheTest method testEmptySecondLevelCacheEntry.
@Test
public void testEmptySecondLevelCacheEntry() throws Exception {
sessionFactory().getCache().evictEntityRegion(Item.class.getName());
Statistics stats = sessionFactory().getStatistics();
stats.clear();
SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(Item.class.getName());
Map cacheEntries = statistics.getEntries();
assertEquals(0, cacheEntries.size());
}
Aggregations