Search in sources :

Example 16 with NearCacheStats

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

the class EvictionChecker method getUsedHeapInBytes.

protected long getUsedHeapInBytes(String mapName) {
    long heapCost = 0L;
    final List<Integer> partitionIds = findPartitionIds();
    for (int partitionId : partitionIds) {
        final PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId);
        if (container == null) {
            continue;
        }
        heapCost += getRecordStoreHeapCost(mapName, container);
    }
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    if (!mapContainer.getMapConfig().isNearCacheEnabled()) {
        return heapCost;
    }
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
    NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
    heapCost += nearCacheStats.getOwnedEntryMemoryCost();
    return heapCost;
}
Also used : MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) NearCacheStats(com.hazelcast.monitor.NearCacheStats) NearCache(com.hazelcast.internal.nearcache.NearCache) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 17 with NearCacheStats

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

the class NearCachedClientMapProxy method getLocalMapStats.

@Override
public LocalMapStats getLocalMapStats() {
    LocalMapStats localMapStats = super.getLocalMapStats();
    NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
    ((LocalMapStatsImpl) localMapStats).setNearCacheStats(nearCacheStats);
    return localMapStats;
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) LocalMapStatsImpl(com.hazelcast.monitor.impl.LocalMapStatsImpl) NearCacheStats(com.hazelcast.monitor.NearCacheStats)

Example 18 with NearCacheStats

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

the class ClientMapNearCacheTest method testNearCacheMisses_whenRepeatedOnSameKey.

@Test
public void testNearCacheMisses_whenRepeatedOnSameKey() {
    IMap<String, Integer> map = getNearCachedMapFromClient(newInvalidationEnabledNearCacheConfig());
    int expectedCacheMisses = 17;
    for (int i = 0; i < expectedCacheMisses; i++) {
        assertNull(map.get("NOT_THERE"));
    }
    NearCacheStats stats = getNearCacheStats(map);
    assertEquals(1, stats.getOwnedEntryCount());
    assertEquals(expectedCacheMisses, stats.getMisses());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NearCacheStats(com.hazelcast.monitor.NearCacheStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with NearCacheStats

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

the class ClientMapNearCacheTest method testNearCacheMisses.

@Test
public void testNearCacheMisses() {
    IMap<String, Integer> map = getNearCachedMapFromClient(newNoInvalidationNearCacheConfig());
    int expectedCacheMisses = 1321;
    for (int i = 0; i < expectedCacheMisses; i++) {
        map.get("NOT_THERE" + i);
    }
    NearCacheStats stats = getNearCacheStats(map);
    assertEquals(expectedCacheMisses, stats.getMisses());
    assertEquals(expectedCacheMisses, stats.getOwnedEntryCount());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NearCacheStats(com.hazelcast.monitor.NearCacheStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with NearCacheStats

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

the class ClientMapNearCacheTest method testGetAllChecksNearCacheFirst.

@Test
public void testGetAllChecksNearCacheFirst() {
    IMap<Integer, Integer> map = getNearCachedMapFromClient(newNoInvalidationNearCacheConfig());
    HashSet<Integer> keys = new HashSet<Integer>();
    int size = 1003;
    for (int i = 0; i < size; i++) {
        map.put(i, i);
        keys.add(i);
    }
    // populate Near Cache
    for (int i = 0; i < size; i++) {
        map.get(i);
    }
    // getAll() generates the Near Cache hits
    map.getAll(keys);
    NearCacheStats stats = getNearCacheStats(map);
    assertEquals(size, stats.getOwnedEntryCount());
    assertEquals(size, stats.getHits());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NearCacheStats(com.hazelcast.monitor.NearCacheStats) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

NearCacheStats (com.hazelcast.monitor.NearCacheStats)22 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Test (org.junit.Test)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 NearCache (com.hazelcast.internal.nearcache.NearCache)3 AssertTask (com.hazelcast.test.AssertTask)3 Config (com.hazelcast.config.Config)2 EvictionConfig (com.hazelcast.config.EvictionConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 MapContainer (com.hazelcast.map.impl.MapContainer)1 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)1 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)1 NearCachedMapProxyImpl (com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl)1 LocalMapStats (com.hazelcast.monitor.LocalMapStats)1 LocalMapStatsImpl (com.hazelcast.monitor.impl.LocalMapStatsImpl)1 SerializationServiceSupport (com.hazelcast.spi.impl.SerializationServiceSupport)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1