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