当前位置: 首页>>代码示例>>Java>>正文


Java SecondLevelCacheStatistics类代码示例

本文整理汇总了Java中org.hibernate.stat.SecondLevelCacheStatistics的典型用法代码示例。如果您正苦于以下问题:Java SecondLevelCacheStatistics类的具体用法?Java SecondLevelCacheStatistics怎么用?Java SecondLevelCacheStatistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SecondLevelCacheStatistics类属于org.hibernate.stat包,在下文中一共展示了SecondLevelCacheStatistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSecondLevelCacheStatistics

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
/**
 * Second level cache statistics per region
 *
 * @param regionName region name
 *
 * @return SecondLevelCacheStatistics
 */
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
	ConcurrentSecondLevelCacheStatisticsImpl slcs
			= (ConcurrentSecondLevelCacheStatisticsImpl) secondLevelCacheStatistics.get( regionName );
	if ( slcs == null ) {
		if ( sessionFactory == null ) {
			return null;
		}
		Region region = sessionFactory.getSecondLevelCacheRegion( regionName );
		if ( region == null ) {
			return null;
		}
		slcs = new ConcurrentSecondLevelCacheStatisticsImpl( region );
		ConcurrentSecondLevelCacheStatisticsImpl previous;
		if ( ( previous = (ConcurrentSecondLevelCacheStatisticsImpl) secondLevelCacheStatistics.putIfAbsent(
				regionName, slcs
		) ) != null ) {
			slcs = previous;
		}
	}
	return slcs;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ConcurrentStatisticsImpl.java

示例2: testUpdateEventuallyInvalidatesObject

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testUpdateEventuallyInvalidatesObject() {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities
    getDummyEntities(sf, 10);

    //hit 1 entity and 4 properties
    updateDummyEntityName(sf, 2, "updated");
    assertSizeEventually(9, dummyEntityCacheStats.getEntries());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:18,代码来源:CacheHitMissNonStrictTest.java

示例3: testGetUpdateRemoveGet

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testGetUpdateRemoveGet()
        throws Exception {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();
    //miss 10 entities
    getDummyEntities(sf, 10);
    //hit 1 entity and 4 properties
    deleteDummyEntity(sf, 1);

    assertEquals(4, dummyPropertyCacheStats.getHitCount());
    assertEquals(0, dummyPropertyCacheStats.getMissCount());
    assertEquals(1, dummyEntityCacheStats.getHitCount());
    assertEquals(10, dummyEntityCacheStats.getMissCount());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:21,代码来源:CacheHitMissReadOnlyTest.java

示例4: testUpdateShouldNotInvalidateEntryInCache

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testUpdateShouldNotInvalidateEntryInCache() {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities, 10 entities are cached
    getDummyEntities(sf, 10);

    //updates cache entity
    updateDummyEntityName(sf, 2, "updated");

    assertEquals(10, dummyEntityCacheStats.getElementCountInMemory());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:18,代码来源:CacheHitMissReadWriteTest.java

示例5: test

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void test() {
    SessionFactory factory = SessionFactoryProvider
            .getInstance().provide(Context.class);
    Statistics statistics = factory.getStatistics();
    SecondLevelCacheStatistics secondStat = factory.getStatistics().getSecondLevelCacheStatistics(GameUser.class.getName());
    deleteAll();
    logger.info("==========>>>deleteAll: second level cache hits: " + statistics.getSecondLevelCacheHitCount());
    logger.info("==========>>>deleteAll: query execution hits: " + statistics.getQueryExecutionCount());
    logger.info("==========>>>deleteAll: element count in mem: " + secondStat.getElementCountInMemory());
    intsert5();
    logger.info("==========>>>intsert5: second level cache hits: " + statistics.getSecondLevelCacheHitCount());
    logger.info("==========>>>intsert5: query execution hits: " + statistics.getQueryExecutionCount());
    logger.info("==========>>>intsert5: element count in mem: " + secondStat.getElementCountInMemory());
    doSomeThing();
    logger.info("==========>>>doSomeThing: second level cache hits: " + statistics.getSecondLevelCacheHitCount());
    logger.info("==========>>>doSomeThing: query execution hits: " + statistics.getQueryExecutionCount());
    logger.info("==========>>>doSomeThing: element count in mem: " + secondStat.getElementCountInMemory());
    deleteAll();
    logger.info("==========>>>deleteAll: second level cache hits: " + statistics.getSecondLevelCacheHitCount());
    logger.info("==========>>>deleteAll: query execution hits: " + statistics.getQueryExecutionCount());
    logger.info("==========>>>deleteAll: element count in mem: " + secondStat.getElementCountInMemory());
}
 
开发者ID:youngmonkeys,项目名称:ezyfox-db,代码行数:24,代码来源:BaseDbTest.java

示例6: testUpdateEventuallyInvalidatesObject

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testUpdateEventuallyInvalidatesObject() {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    final SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities
    getDummyEntities(sf, 10);

    //hit 1 entity and 4 properties
    updateDummyEntityName(sf, 2, "updated");
    assertSizeEventually(9, dummyEntityCacheStats.getEntries());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:18,代码来源:CacheHitMissNonStrictTest.java

示例7: assertCollectionCache

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
/**
 * @param sesFactory Session factory.
 * @param idToChildCnt Number of children per entity.
 * @param expHit Expected cache hits.
 * @param expMiss Expected cache misses.
 */
@SuppressWarnings("unchecked")
private void assertCollectionCache(SessionFactory sesFactory, Map<Integer, Integer> idToChildCnt, int expHit,
    int expMiss) {
    sesFactory.getStatistics().clear();

    Session ses = sesFactory.openSession();

    try {
        for(Map.Entry<Integer, Integer> e : idToChildCnt.entrySet()) {
            Entity entity = (Entity)ses.load(Entity.class, e.getKey());

            assertEquals((int)e.getValue(), entity.getChildren().size());
        }
    }
    finally {
        ses.close();
    }

    SecondLevelCacheStatistics stats =
        sesFactory.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);

    assertEquals(expHit, stats.getHitCount());

    assertEquals(expMiss, stats.getMissCount());
}
 
开发者ID:apache,项目名称:ignite,代码行数:32,代码来源:HibernateL2CacheSelfTest.java

示例8: printStats

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
/**
 * Prints Hibernate L2 cache statistics to standard output.
 *
 * @param sesFactory Hibernate {@link SessionFactory}, for which to print
 *                   statistics.
 */
private static void printStats(SessionFactory sesFactory) {
    System.out.println("=== Hibernate L2 cache statistics ===");

    for (String entityName : ENTITY_NAMES) {
        System.out.println("\tEntity: " + entityName);

        SecondLevelCacheStatistics stats =
            sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);

        System.out.println("\t\tPuts: " + stats.getPutCount());
        System.out.println("\t\tHits: " + stats.getHitCount());
        System.out.println("\t\tMisses: " + stats.getMissCount());
    }

    System.out.println("=====================================");
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:HibernateL2CacheExample.java

示例9: testGetUpdateRemoveGet

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testGetUpdateRemoveGet()
        throws Exception {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities
    getDummyEntities(sf, 10);

    //hit 1 entity and 4 properties
    updateDummyEntityName(sf, 2, "updated");

    //entity 2 and its properties are invalidated

    //miss updated entity, hit 4 properties(they are still the same)
    getPropertiesOfEntity(sf, 2);

    //hit 1 entity and 4 properties
    deleteDummyEntity(sf, 1);

    assertEquals(12, dummyPropertyCacheStats.getHitCount());
    assertEquals(0, dummyPropertyCacheStats.getMissCount());
    assertEquals(2, dummyEntityCacheStats.getHitCount());
    assertEquals(11, dummyEntityCacheStats.getMissCount());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:31,代码来源:CacheHitMissNonStrictTest.java

示例10: testUpdateQueryCausesInvalidationOfEntireRegion

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testUpdateQueryCausesInvalidationOfEntireRegion() {
    insertDummyEntities(10);

    executeUpdateQuery(sf, "UPDATE DummyEntity set name = 'manually-updated' where id=2");

    sf.getStatistics().clear();

    getDummyEntities(sf, 10);

    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    assertEquals(10, dummyEntityCacheStats.getMissCount());
    assertEquals(0, dummyEntityCacheStats.getHitCount());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:15,代码来源:HibernateStatisticsTestSupport.java

示例11: testUpdateQueryCausesInvalidationOfEntireCollectionRegion

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testUpdateQueryCausesInvalidationOfEntireCollectionRegion() {
    insertDummyEntities(1, 10);

    //properties reference in DummyEntity is evicted because of custom SQL query on Collection region
    executeUpdateQuery(sf, "update DummyProperty ent set ent.key='manually-updated'");
    sf.getStatistics().clear();

    //property reference missed in cache.
    getPropertiesOfEntity(sf, 0);

    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY + ".properties");
    assertEquals(0, dummyPropertyCacheStats.getHitCount());
    assertEquals(1, dummyPropertyCacheStats.getMissCount());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:16,代码来源:HibernateStatisticsTestSupport.java

示例12: testGetUpdateRemoveGet

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testGetUpdateRemoveGet()
        throws Exception {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities
    getDummyEntities(sf, 10);

    //hit 1 entity and 4 properties
    updateDummyEntityName(sf, 2, "updated");

    //hit 1 entity, hit 4 properties
    getPropertiesOfEntity(sf, 2);
    //hit 1 entity and 4 properties
    deleteDummyEntity(sf, 1);

    assertEquals(12, dummyPropertyCacheStats.getHitCount());
    assertEquals(0, dummyPropertyCacheStats.getMissCount());
    assertEquals(3, dummyEntityCacheStats.getHitCount());
    assertEquals(10, dummyEntityCacheStats.getMissCount());

}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:29,代码来源:CacheHitMissReadWriteTest.java

示例13: testGetUpdateRemoveGet

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
@Test
public void testGetUpdateRemoveGet()
        throws Exception {
    insertDummyEntities(10, 4);
    //all 10 entities and 40 properties are cached
    SecondLevelCacheStatistics dummyEntityCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_ENTITY);
    SecondLevelCacheStatistics dummyPropertyCacheStats = sf.getStatistics().getSecondLevelCacheStatistics(CACHE_PROPERTY);

    sf.getCache().evictEntityRegions();
    sf.getCache().evictCollectionRegions();

    //miss 10 entities
    getDummyEntities(sf, 10);

    //hit 1 entity and 4 properties
    updateDummyEntityName(sf, 2, "updated");
    //invalidation is not synchronized, so we have to wait
    //entity 2 and its properties are invalidated

    //miss updated entity, hit 4 properties(they are still the same)
    getPropertiesOfEntity(sf, 2);

    //hit 1 entity and 4 properties
    deleteDummyEntity(sf, 1);

    assertEquals(12, dummyPropertyCacheStats.getHitCount());
    assertEquals(0, dummyPropertyCacheStats.getMissCount());
    assertEquals(2, dummyEntityCacheStats.getHitCount());
    assertEquals(11, dummyEntityCacheStats.getMissCount());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:31,代码来源:CacheHitMissNonStrictTest.java

示例14: testEmptySecondLevelCacheEntry

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
public void testEmptySecondLevelCacheEntry() throws Exception {
	getSessions().evictEntity( Item.class.getName() );
	Statistics stats = getSessions().getStatistics();
	stats.clear();
	SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( Item.class.getName() );
       Map cacheEntries = statistics.getEntries();
	assertEquals( 0, cacheEntries.size() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:BaseCacheProviderTestCase.java

示例15: printEntityCacheStats

import org.hibernate.stat.SecondLevelCacheStatistics; //导入依赖的package包/类
protected void printEntityCacheStats(String region, boolean printEntries) {
	SecondLevelCacheStatistics stats = getCacheStats(region);
	LOGGER.info(region + " Stats:  \n\n\t" + stats + "\n");
	if (printEntries) {
		@SuppressWarnings("rawtypes")
		Map cacheEntries = stats.getEntries();
		LOGGER.info(Arrays.toString(cacheEntries.entrySet().toArray()));
	}
}
 
开发者ID:vladmihalcea,项目名称:hibernate-master-class,代码行数:10,代码来源:AbstractTest.java


注:本文中的org.hibernate.stat.SecondLevelCacheStatistics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。