use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class LocalMapStatsProvider method addNearCacheStats.
private void addNearCacheStats(String mapName, LocalMapStatsImpl localMapStats, LocalMapOnDemandCalculatedStats onDemandStats) {
NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
if (nearCache == null) {
return;
}
NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
localMapStats.setNearCacheStats(nearCacheStats);
onDemandStats.incrementHeapCost(nearCacheStats.getOwnedEntryMemoryCost());
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientCacheNearCacheCacheOnUpdateTest method with_invalidate_policy_concurrently_updated_near_cache_causes_misses.
@Test
public void with_invalidate_policy_concurrently_updated_near_cache_causes_misses() {
ICache<Integer, Integer> nearCachedClientCache = newNearCachedCache(INVALIDATE);
checkNearCacheInstance(nearCachedClientCache);
runTest(nearCachedClientCache, INVALIDATE);
NearCacheStats nearCacheStatistics = nearCachedClientCache.getLocalCacheStatistics().getNearCacheStatistics();
assertTrue(nearCacheStatistics.toString(), nearCacheStatistics.getMisses() > 0);
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientCacheReconciliationTest method test_reconciliation_does_not_cause_premature_removal.
@Test
public void test_reconciliation_does_not_cause_premature_removal() {
int total = 100;
for (int i = 0; i < total; i++) {
serverCache1.put(i, i);
}
clientCache1 = createCacheFromNewClient(CACHE_1_NAME);
for (int i = 0; i < total; i++) {
clientCache1.get(i);
}
NearCacheStats nearCacheStats = getNearCacheStatisticsOf(clientCache1);
assertStats(CACHE_1_NAME, nearCacheStats, total, 0, total);
sleepSeconds(2 * RECONCILIATION_INTERVAL_SECS);
for (int i = 0; i < total; i++) {
clientCache1.get(i);
}
assertStats(CACHE_1_NAME, nearCacheStats, total, total, total);
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class NearCacheStatsStressTest method stress_stats_by_doing_put_and_remove.
@Test
public void stress_stats_by_doing_put_and_remove() throws Exception {
ExecutorService pool = Executors.newFixedThreadPool(2);
pool.execute(new Put());
pool.execute(new Remove());
sleepSeconds(3);
stop.set(true);
pool.shutdown();
if (pool.awaitTermination(10, SECONDS)) {
NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
long ownedEntryCount = nearCacheStats.getOwnedEntryCount();
long memoryCost = nearCacheStats.getOwnedEntryMemoryCost();
int size = nearCache.size();
assertTrue("ownedEntryCount=" + ownedEntryCount + ", size=" + size, ownedEntryCount >= 0);
assertTrue("memoryCost=" + memoryCost + ", size=" + size, memoryCost >= 0);
assertEquals("ownedEntryCount=" + ownedEntryCount + ", size=" + size, size, ownedEntryCount);
} else {
fail("pool.awaitTermination reached timeout before termination");
}
}
use of com.hazelcast.nearcache.NearCacheStats in project hazelcast by hazelcast.
the class ClientMapReconciliationTest method test_reconciliation_does_not_cause_premature_removal.
@Test
public void test_reconciliation_does_not_cause_premature_removal() {
int total = 100;
for (int i = 0; i < total; i++) {
serverMap1.put(i, i);
}
clientMap1 = createMapFromNewClient(MAP_1_NAME);
for (int i = 0; i < total; i++) {
clientMap1.get(i);
}
IMap mapFromNewClient = createMapFromNewClient(MAP_1_NAME);
for (int i = 0; i < total; i++) {
mapFromNewClient.get(i);
}
NearCacheStats nearCacheStats = mapFromNewClient.getLocalMapStats().getNearCacheStats();
assertStats(MAP_1_NAME, nearCacheStats, total, 0, total);
sleepSeconds(2 * RECONCILIATION_INTERVAL_SECS);
for (int i = 0; i < total; i++) {
mapFromNewClient.get(i);
}
assertStats(MAP_1_NAME, nearCacheStats, total, total, total);
}
Aggregations