Search in sources :

Example 56 with Statistics

use of org.hibernate.stat.Statistics in project wildfly by wildfly.

the class DummyEntityCustomRegionRESTResource method clearStatistics.

@GET
@Path("/clear-statistics")
@Produces("text/plain")
public Response clearStatistics() {
    Statistics stats = em.unwrap(Session.class).getSessionFactory().getStatistics();
    stats.clear();
    return Response.ok().build();
}
Also used : Statistics(org.hibernate.stat.Statistics) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 57 with Statistics

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;
}
Also used : Statistics(org.hibernate.stat.Statistics) LinkedHashMap(java.util.LinkedHashMap)

Example 58 with Statistics

use of org.hibernate.stat.Statistics in project openolat by klemens.

the class DatabaseWebService method getHibernateStatistics.

private HibernateStatisticsVO getHibernateStatistics() {
    Statistics statistics = DBFactory.getInstance().getStatistics();
    if (!statistics.isStatisticsEnabled()) {
        return null;
    }
    HibernateStatisticsVO stats = new HibernateStatisticsVO();
    stats.setOpenSessionsCount(statistics.getSessionOpenCount());
    stats.setTransactionsCount(statistics.getTransactionCount());
    stats.setSuccessfulTransactionCount(statistics.getSuccessfulTransactionCount());
    stats.setFailedTransactionsCount(statistics.getTransactionCount() - statistics.getSuccessfulTransactionCount());
    stats.setOptimisticFailureCount(statistics.getOptimisticFailureCount());
    stats.setQueryExecutionCount(statistics.getQueryExecutionCount());
    stats.setQueryExecutionMaxTime(statistics.getQueryExecutionMaxTime());
    stats.setQueryExecutionMaxTimeQueryString(statistics.getQueryExecutionMaxTimeQueryString());
    return stats;
}
Also used : HibernateStatisticsVO(org.olat.restapi.system.vo.HibernateStatisticsVO) Statistics(org.hibernate.stat.Statistics)

Example 59 with Statistics

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;
}
Also used : CompositeData(javax.management.openmbean.CompositeData) ArrayList(java.util.ArrayList) Statistics(org.hibernate.stat.Statistics) TabularData(javax.management.openmbean.TabularData)

Example 60 with Statistics

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;
}
Also used : CompositeData(javax.management.openmbean.CompositeData) ArrayList(java.util.ArrayList) Statistics(org.hibernate.stat.Statistics) TabularData(javax.management.openmbean.TabularData)

Aggregations

Statistics (org.hibernate.stat.Statistics)97 Test (org.junit.Test)59 Session (org.hibernate.Session)27 SecondLevelCacheStatistics (org.hibernate.stat.SecondLevelCacheStatistics)26 EntityManager (javax.persistence.EntityManager)21 QueryStatistics (org.hibernate.stat.QueryStatistics)19 Item (org.hibernate.test.cache.infinispan.functional.entities.Item)14 Transaction (org.hibernate.Transaction)12 ArrayList (java.util.ArrayList)11 VersionedItem (org.hibernate.test.cache.infinispan.functional.entities.VersionedItem)11 List (java.util.List)10 OtherItem (org.hibernate.test.cache.infinispan.functional.entities.OtherItem)10 SessionFactory (org.hibernate.SessionFactory)9 CacheRegionStatistics (org.hibernate.stat.CacheRegionStatistics)9 ByRef (org.infinispan.commons.util.ByRef)8 TestForIssue (org.hibernate.testing.TestForIssue)6 Date (java.util.Date)5 UserTransaction (javax.transaction.UserTransaction)5 NaturalIdCacheStatistics (org.hibernate.stat.NaturalIdCacheStatistics)5 Test (org.testng.annotations.Test)5