Search in sources :

Example 31 with NearCacheStats

use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.

the class NearCacheTest method testNearCacheEntriesNotExpired_afterIMapExpiration.

/**
 * Near Cache has its own eviction/expiration mechanism, so eviction/expiration on an IMap
 * should not force any Near Cache eviction/expiration. Exceptions from this rule are direct calls to
 * <ul>
 * <li>{@link IMap#evict(Object)}</li>
 * <li>{@link IMap#evictAll()}</li>
 * </ul>
 */
@Test
public void testNearCacheEntriesNotExpired_afterIMapExpiration() {
    int mapSize = 3;
    String mapName = randomMapName();
    Config config = createNearCachedMapConfig(mapName);
    HazelcastInstance instance = createHazelcastInstance(config);
    IMap<Integer, Integer> map = instance.getMap(mapName);
    CountDownLatch latch = new CountDownLatch(mapSize);
    addEntryExpiredListener(map, latch);
    populateMapWithExpirableEntries(map, mapSize, 3, TimeUnit.SECONDS);
    populateNearCache(map, mapSize);
    int nearCacheSizeBeforeExpiration = getNearCacheSize(map);
    waitUntilEvictionEventsReceived(latch);
    // wait some extra time for possible events
    sleepSeconds(2);
    int nearCacheSizeAfterExpiration = getNearCacheSize(map);
    NearCacheStats stats = getNearCacheStats(map);
    assertEquals(0, stats.getExpirations());
    assertEquals(0, stats.getEvictions());
    assertEquals(nearCacheSizeBeforeExpiration, nearCacheSizeAfterExpiration);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

NearCacheStats (com.hazelcast.nearcache.NearCacheStats)31 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)22 QuickTest (com.hazelcast.test.annotation.QuickTest)22 Test (org.junit.Test)22 NightlyTest (com.hazelcast.test.annotation.NightlyTest)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 NearCacheConfig (com.hazelcast.config.NearCacheConfig)5 NearCache (com.hazelcast.internal.nearcache.NearCache)5 TransactionContext (com.hazelcast.transaction.TransactionContext)5 Config (com.hazelcast.config.Config)3 MapConfig (com.hazelcast.config.MapConfig)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 IMap (com.hazelcast.map.IMap)2 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 NearCacheStatsImpl (com.hazelcast.internal.monitor.impl.NearCacheStatsImpl)1 DefaultNearCache (com.hazelcast.internal.nearcache.impl.DefaultNearCache)1 NearCacheTestUtils.getRecordFromNearCache (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getRecordFromNearCache)1 NearCacheTestUtils.getValueFromNearCache (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getValueFromNearCache)1 LocalMapStats (com.hazelcast.map.LocalMapStats)1 LocalIndexStats (com.hazelcast.query.LocalIndexStats)1