Search in sources :

Example 1 with NearCacheStats

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);
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) TransactionContext(com.hazelcast.transaction.TransactionContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with NearCacheStats

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);
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) TransactionContext(com.hazelcast.transaction.TransactionContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with NearCacheStats

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;
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) NearCache(com.hazelcast.internal.nearcache.NearCache)

Example 4 with NearCacheStats

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);
    });
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) Map(java.util.Map) LocalIndexStats(com.hazelcast.query.LocalIndexStats)

Example 5 with NearCacheStats

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());
}
Also used : NearCacheStats(com.hazelcast.nearcache.NearCacheStats) DefaultNearCache(com.hazelcast.internal.nearcache.impl.DefaultNearCache) NearCache(com.hazelcast.internal.nearcache.NearCache) 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