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;
}
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;
}
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());
}
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());
}
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());
}
Aggregations