Search in sources :

Example 16 with NearCacheStats

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

the class LocalMapStatsProvider method addNearCacheStats.

private void addNearCacheStats(String mapName, LocalMapStatsImpl localMapStats, LocalMapOnDemandCalculatedStats onDemandStats) {
    NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
    if (nearCache == null) {
        return;
    }
    NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
    localMapStats.setNearCacheStats(nearCacheStats);
    onDemandStats.incrementHeapCost(nearCacheStats.getOwnedEntryMemoryCost());
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) NearCache(com.hazelcast.internal.nearcache.NearCache)

Example 17 with NearCacheStats

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

the class ClientCacheNearCacheCacheOnUpdateTest method with_invalidate_policy_concurrently_updated_near_cache_causes_misses.

@Test
public void with_invalidate_policy_concurrently_updated_near_cache_causes_misses() {
    ICache<Integer, Integer> nearCachedClientCache = newNearCachedCache(INVALIDATE);
    checkNearCacheInstance(nearCachedClientCache);
    runTest(nearCachedClientCache, INVALIDATE);
    NearCacheStats nearCacheStatistics = nearCachedClientCache.getLocalCacheStatistics().getNearCacheStatistics();
    assertTrue(nearCacheStatistics.toString(), nearCacheStatistics.getMisses() > 0);
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with NearCacheStats

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

the class ClientCacheReconciliationTest method test_reconciliation_does_not_cause_premature_removal.

@Test
public void test_reconciliation_does_not_cause_premature_removal() {
    int total = 100;
    for (int i = 0; i < total; i++) {
        serverCache1.put(i, i);
    }
    clientCache1 = createCacheFromNewClient(CACHE_1_NAME);
    for (int i = 0; i < total; i++) {
        clientCache1.get(i);
    }
    NearCacheStats nearCacheStats = getNearCacheStatisticsOf(clientCache1);
    assertStats(CACHE_1_NAME, nearCacheStats, total, 0, total);
    sleepSeconds(2 * RECONCILIATION_INTERVAL_SECS);
    for (int i = 0; i < total; i++) {
        clientCache1.get(i);
    }
    assertStats(CACHE_1_NAME, nearCacheStats, total, total, total);
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with NearCacheStats

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

the class NearCacheStatsStressTest method stress_stats_by_doing_put_and_remove.

@Test
public void stress_stats_by_doing_put_and_remove() throws Exception {
    ExecutorService pool = Executors.newFixedThreadPool(2);
    pool.execute(new Put());
    pool.execute(new Remove());
    sleepSeconds(3);
    stop.set(true);
    pool.shutdown();
    if (pool.awaitTermination(10, SECONDS)) {
        NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
        long ownedEntryCount = nearCacheStats.getOwnedEntryCount();
        long memoryCost = nearCacheStats.getOwnedEntryMemoryCost();
        int size = nearCache.size();
        assertTrue("ownedEntryCount=" + ownedEntryCount + ", size=" + size, ownedEntryCount >= 0);
        assertTrue("memoryCost=" + memoryCost + ", size=" + size, memoryCost >= 0);
        assertEquals("ownedEntryCount=" + ownedEntryCount + ", size=" + size, size, ownedEntryCount);
    } else {
        fail("pool.awaitTermination reached timeout before termination");
    }
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) ExecutorService(java.util.concurrent.ExecutorService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with NearCacheStats

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

the class ClientMapReconciliationTest method test_reconciliation_does_not_cause_premature_removal.

@Test
public void test_reconciliation_does_not_cause_premature_removal() {
    int total = 100;
    for (int i = 0; i < total; i++) {
        serverMap1.put(i, i);
    }
    clientMap1 = createMapFromNewClient(MAP_1_NAME);
    for (int i = 0; i < total; i++) {
        clientMap1.get(i);
    }
    IMap mapFromNewClient = createMapFromNewClient(MAP_1_NAME);
    for (int i = 0; i < total; i++) {
        mapFromNewClient.get(i);
    }
    NearCacheStats nearCacheStats = mapFromNewClient.getLocalMapStats().getNearCacheStats();
    assertStats(MAP_1_NAME, nearCacheStats, total, 0, total);
    sleepSeconds(2 * RECONCILIATION_INTERVAL_SECS);
    for (int i = 0; i < total; i++) {
        mapFromNewClient.get(i);
    }
    assertStats(MAP_1_NAME, nearCacheStats, total, total, total);
}
Also used : IMap(com.hazelcast.map.IMap) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) 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