Search in sources :

Example 21 with NearCacheStats

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

the class ClientMapNearCacheTest method testNearCachePopulatedAndHitsGenerated.

@Test
public void testNearCachePopulatedAndHitsGenerated() {
    IMap<Integer, Integer> map = getNearCachedMapFromClient(newNoInvalidationNearCacheConfig());
    int size = 1278;
    populateMap(map, size);
    populateNearCache(map, size);
    for (int i = 0; i < size; i++) {
        // generate Near Cache hits
        map.get(i);
    }
    NearCacheStats stats = getNearCacheStats(map);
    assertEquals(size, stats.getOwnedEntryCount());
    assertEquals(size, stats.getHits());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 22 with NearCacheStats

use of com.hazelcast.nearcache.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.nearcache.NearCacheStats) HashSet(java.util.HashSet) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 23 with NearCacheStats

use of com.hazelcast.nearcache.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.nearcache.NearCacheStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 24 with NearCacheStats

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

the class ClientTxnMapNearCacheTest method replace_invalidates_server_side_near_cache.

@Test
public void replace_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.replace(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 25 with NearCacheStats

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

the class ClientTxnMapNearCacheTest method put_invalidates_server_side_near_cache.

@Test
public void put_invalidates_server_side_near_cache() {
    // update map in a client txn
    TransactionContext context = client.newTransactionContext();
    context.beginTransaction();
    TransactionalMap<Object, Object> txnMap = context.getMap(MAP_NAME);
    for (int i = 0; i < KEY_COUNT; i++) {
        txnMap.put(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)

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