Package org.hibernate.stat

Examples of org.hibernate.stat.Statistics


            assertEquals("Galaxy for Planet " + s2.getPlanetName() + " was read from second level cache = " + s2.getGalaxy(),
                    "MILKY WAY", s2.getGalaxy());

            assertEquals(s2.getSatellites().size(), 1);

            Statistics stats = sfsb.getStatistics();

            assertEquals(stats.getCollectionLoadCount(), 1);
            assertEquals(stats.getEntityLoadCount(), 2);
            assertEquals(stats.getSecondLevelCacheHitCount(), 1);
            // Collection in secondlevel cache before eviction
            assertTrue(sfsb.isSatellitesPresentInCache(1));

            Statistics statsAfterEviction = sfsb.getStatisticsAfterEviction();
            // Collection in secondlevel cache after eviction
            assertFalse(sfsb.isSatellitesPresentInCache(1));
        } finally {
            sfsb.cleanup();
        }
View Full Code Here


        return query;
    }

    // fetch statistics
    public Statistics getStatistics() {
        Statistics sessionStats = sessionFactory.getStatistics();
        return sessionStats;
    }
View Full Code Here

                assertEquals("EARTH", planet.getPlanetName());
            }

            // fetch statistics

            Statistics stats = sfsb.getStatistics();

            // fetch queries from statistics
            String[] queryList = stats.getQueries();

            // test list of queries obtained from statistics
            for (int i = 0; i < queryList.length; i++) {

                System.out.println("Query obtained from statistics::" + queryList[i]);
View Full Code Here

        return indicator;
    }

    // fetch statistics
    public Statistics getStatistics() {
        Statistics sessionStats = sessionFactory.getStatistics();
        return sessionStats;
    }
View Full Code Here

    // fetch statistics after eviction of collection from cache
    public Statistics getStatisticsAfterEviction() {
        sessionFactory.getCache().evictCollection(
                org.jboss.as.test.integration.hibernate.Planet.class.getName() + ".satellites", new Integer(1));
        Statistics sessionStats = sessionFactory.getStatistics();
        return sessionStats;
    }
View Full Code Here

      return;
    }
    NumberFormat decimalFormat = NumberFormat.getNumberInstance();
    decimalFormat.setGroupingUsed(true);

    Statistics statistics = session.getSessionFactory().getStatistics();

    Runtime runtime = Runtime.getRuntime();

    Collectors collectors = new Collectors(Arrays.asList(new HibernateStatisticsCollector(statistics), new RuntimeStatisticsCollector(runtime)));
    collectStatistics(collectors);

    C3P0PooledDataSource c3p0PooledDataSource = new C3P0PooledDataSource();
    result.include("maxPoolSize", c3p0PooledDataSource.getMaxPoolSize());
    result.include("initPoolSize", c3p0PooledDataSource.getInitialPoolSize());
    result.include("minPoolSize", c3p0PooledDataSource.getMinPoolSize());

    String[] queries = statistics.getQueries();
    List<QueryStatsWrapper> queryStatsList = new ArrayList<QueryStatsWrapper>();
    for (String query : queries) {
      QueryStatistics queryStats = statistics.getQueryStatistics(query);
      queryStatsList.add(new QueryStatsWrapper(query, queryStats));
    }
    result.include("queryStatsList", queryStatsList);

    String[] entityNames = statistics.getEntityNames();
    Map<String, EntityCacheStatsWrapper> entityCacheStats = new HashMap<String, EntityCacheStatsWrapper>();

    for (String entityName : entityNames) {
      EntityStatistics entityStatistics = statistics.getEntityStatistics(entityName);
      EntityCacheStatsWrapper entityCacheStatsWrapper = new EntityCacheStatsWrapper();
      entityCacheStatsWrapper.setEntityStatsWrapper(new EntityStatsWrapper(entityName, entityStatistics));
      entityCacheStats.put(entityName, entityCacheStatsWrapper);
    }

    for (String regionName : statistics.getSecondLevelCacheRegionNames()) {
      CacheStatsWrapper cacheStatsWrapper = new CacheStatsWrapper(regionName, statistics.getSecondLevelCacheStatistics(regionName));
      if(entityCacheStats.containsKey(regionName)){
        EntityCacheStatsWrapper entityCacheStatsWrapper = entityCacheStats.get(regionName);
        EntityCacheStatsWrapper entityStatsWrapper = entityCacheStatsWrapper;
        entityStatsWrapper.setCacheStatsWrapper(cacheStatsWrapper);
      }
      else {
        EntityCacheStatsWrapper entityCacheStatsWrapper = new EntityCacheStatsWrapper();
        entityCacheStatsWrapper.setCacheStatsWrapper(cacheStatsWrapper);
        entityCacheStats.put(regionName, entityCacheStatsWrapper);
      }
    }

    result.include("entityCacheStats", entityCacheStats);


    List<CollectionStatsWrapper> collectionsStatsList = new ArrayList<CollectionStatsWrapper>();
    for (String collectionRoleName : statistics.getCollectionRoleNames()) {
      collectionsStatsList.add(new CollectionStatsWrapper(collectionRoleName, statistics));
    }
    result.include("collectionsStatsList", collectionsStatsList);

    List<net.sf.ehcache.Statistics> collectionsCacheStatsList = new ArrayList<net.sf.ehcache.Statistics>();
View Full Code Here

public class CacheAction extends BaseAction {

  private SessionFactory sessionFactory;

  public String index() {
    Statistics statistics = sessionFactory.getStatistics();
    Date lastUpdate = new Date();
    Date activation = null;
    Date deactivation = null;

    boolean active = statistics.isStatisticsEnabled();
    List<Long> generalStatistics = Collections.synchronizedList(new ArrayList<Long>(18));
    if (active) {
      generalStatistics.add(statistics.getConnectCount());
      generalStatistics.add(statistics.getFlushCount());

      generalStatistics.add(statistics.getPrepareStatementCount());
      generalStatistics.add(statistics.getCloseStatementCount());

      generalStatistics.add(statistics.getSessionCloseCount());
      generalStatistics.add(statistics.getSessionOpenCount());

      generalStatistics.add(statistics.getTransactionCount());
      generalStatistics.add(statistics.getSuccessfulTransactionCount());
      generalStatistics.add(statistics.getOptimisticFailureCount());
    }
    final String action = get("do");
    final StringBuilder info = new StringBuilder(512);

    if ("activate".equals(action) && !statistics.isStatisticsEnabled()) {
      statistics.setStatisticsEnabled(true);
      activation = new Date();
      info.append("Statistics enabled\n");
    } else if ("deactivate".equals(action) && statistics.isStatisticsEnabled()) {
      statistics.setStatisticsEnabled(false);
      deactivation = new Date();
      info.append("Statistics disabled\n");
    } else if ("clear".equals(action)) {
      activation = null;
      deactivation = null;
      statistics.clear();
      generalStatistics.clear();
      info.append("Statistics cleared\n");
    }
    addActionMessage(info.toString());
    put("active", active);
View Full Code Here

  public String conf() {
    return forward();
  }

  public String entity() {
    Statistics statistics = sessionFactory.getStatistics();
    put("statistics", statistics);
    return forward();
  }
View Full Code Here

    put("statistics", statistics);
    return forward();
  }

  public String query() {
    Statistics statistics = sessionFactory.getStatistics();
    put("statistics", statistics);
    return forward("queryCache");
  }
View Full Code Here

    put("statistics", statistics);
    return forward("queryCache");
  }

  public String collection() {
    Statistics statistics = sessionFactory.getStatistics();
    put("statistics", statistics);
    return forward();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.stat.Statistics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.