use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientTxnMapNearCacheTest method remove_invalidates_server_side_near_cache.
@Test
public void remove_invalidates_server_side_near_cache() {
TransactionContext context = client.newTransactionContext();
context.beginTransaction();
TransactionalMap<Object, Object> txnMap = context.getMap(MAP_NAME);
for (int i = 0; i < KEY_COUNT; i++) {
txnMap.remove(i);
}
context.commitTransaction();
NearCacheStats nearCacheStats = serverMap.getLocalMapStats().getNearCacheStats();
long ownedEntryCount = nearCacheStats.getOwnedEntryCount();
long invalidations = nearCacheStats.getInvalidations();
assertEquals(0, ownedEntryCount);
assertEquals(KEY_COUNT, invalidations);
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientTxnMapNearCacheTest method removeIfSame_invalidates_server_side_near_cache.
@Test
public void removeIfSame_invalidates_server_side_near_cache() {
TransactionContext context = client.newTransactionContext();
context.beginTransaction();
TransactionalMap<Object, Object> txnMap = context.getMap(MAP_NAME);
for (int i = 0; i < KEY_COUNT; i++) {
txnMap.remove(i, i);
}
context.commitTransaction();
NearCacheStats nearCacheStats = serverMap.getLocalMapStats().getNearCacheStats();
long ownedEntryCount = nearCacheStats.getOwnedEntryCount();
long invalidations = nearCacheStats.getInvalidations();
assertEquals(0, ownedEntryCount);
assertEquals(KEY_COUNT, invalidations);
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class EvictionChecker method usedHeapInBytes.
private long usedHeapInBytes(String mapName) {
long usedHeapInBytes = 0L;
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
usedHeapInBytes += getRecordStoreHeapCost(mapName, containers[partitionId]);
}
NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
if (nearCache != null) {
NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
usedHeapInBytes += nearCacheStats.getOwnedEntryMemoryCost();
}
return usedHeapInBytes;
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class MapService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
Map<String, LocalMapStats> stats = getStats();
if (stats == null) {
return;
}
for (Map.Entry<String, LocalMapStats> entry : stats.entrySet()) {
String mapName = entry.getKey();
LocalMapStats localInstanceStats = entry.getValue();
// map
MetricDescriptor dsDescriptor = descriptor.copy().withPrefix(MAP_PREFIX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
context.collect(dsDescriptor, localInstanceStats);
// index
Map<String, LocalIndexStats> indexStats = localInstanceStats.getIndexStats();
for (Map.Entry<String, LocalIndexStats> indexEntry : indexStats.entrySet()) {
MetricDescriptor indexDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_INDEX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName).withTag(MAP_TAG_INDEX, indexEntry.getKey());
context.collect(indexDescriptor, indexEntry.getValue());
}
// near cache
NearCacheStats nearCacheStats = localInstanceStats.getNearCacheStats();
if (nearCacheStats != null) {
MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_NEARCACHE).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
context.collect(nearCacheDescriptor, nearCacheStats);
}
}
// stats of offloaded-entry-processor's executor
ExecutorStats executorStats = mapServiceContext.getOffloadedEntryProcessorExecutorStats();
executorStats.getStatsMap().forEach((name, offloadedExecutorStats) -> {
MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_ENTRY_PROCESSOR_OFFLOADABLE_EXECUTOR).withDiscriminator(MAP_DISCRIMINATOR_NAME, name);
context.collect(nearCacheDescriptor, offloadedExecutorStats);
});
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientCacheNearCacheCacheOnUpdateTest method with_cacheOnUpdate_policy_concurrently_updated_near_cache_does_not_cause_any_miss.
@Test
public void with_cacheOnUpdate_policy_concurrently_updated_near_cache_does_not_cause_any_miss() {
ICache<Integer, Integer> nearCachedClientCache = newNearCachedCache(CACHE_ON_UPDATE);
checkNearCacheInstance(nearCachedClientCache);
runTest(nearCachedClientCache, CACHE_ON_UPDATE);
NearCache nearCache = ((NearCachedClientCacheProxy) nearCachedClientCache).getNearCache();
int size = nearCache.size();
NearCacheStats nearCacheStatistics = nearCachedClientCache.getLocalCacheStatistics().getNearCacheStatistics();
assertEquals(size + ", " + nearCacheStatistics.toString() + ", " + nearCache.getNearCacheConfig(), 0, nearCacheStatistics.getMisses());
}
Aggregations