use of com.hazelcast.cache.CacheStatistics in project hazelcast by hazelcast.
the class CacheStatsTest method testGetStat.
@Test
public void testGetStat() {
ICache<Integer, String> cache = createCache();
CacheStatistics stats = cache.getLocalCacheStatistics();
final int ENTRY_COUNT = 100;
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.put(i, "Value-" + i);
}
for (int i = 0; i < 2 * ENTRY_COUNT; i++) {
cache.get(i);
}
assertEquals(2 * ENTRY_COUNT, stats.getCacheGets());
}
use of com.hazelcast.cache.CacheStatistics in project hazelcast by hazelcast.
the class CacheStatsTest method testCreationTime.
@Test
public void testCreationTime() {
long now = System.currentTimeMillis();
ICache<Integer, String> cache = createCache();
CacheStatistics stats = cache.getLocalCacheStatistics();
assertTrue(stats.getCreationTime() >= now);
}
use of com.hazelcast.cache.CacheStatistics in project hazelcast by hazelcast.
the class CacheStatsTest method testLastUpdateTimeStat.
@Test
public void testLastUpdateTimeStat() {
ICache<Integer, String> cache = createCache();
CacheStatistics stats = cache.getLocalCacheStatistics();
final int ENTRY_COUNT = 100;
long start, end;
start = System.currentTimeMillis();
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.put(i, "Value-" + i);
}
end = System.currentTimeMillis();
assertTrue(stats.getLastUpdateTime() >= start);
assertTrue(stats.getLastUpdateTime() <= end);
start = System.currentTimeMillis();
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.remove(i);
}
end = System.currentTimeMillis();
assertTrue(stats.getLastUpdateTime() >= start);
assertTrue(stats.getLastUpdateTime() <= end);
long currentLastUpdateTime = stats.getLastUpdateTime();
sleepAtLeastMillis(1);
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.remove(i);
}
// Latest removes has no effect since keys are already removed at previous loop
assertEquals(currentLastUpdateTime, stats.getLastUpdateTime());
}
use of com.hazelcast.cache.CacheStatistics in project hazelcast by hazelcast.
the class CacheStatsTest method testRemoveStat.
@Test
public void testRemoveStat() {
ICache<Integer, String> cache = createCache();
CacheStatistics stats = cache.getLocalCacheStatistics();
final int ENTRY_COUNT = 100;
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.put(i, "Value-" + i);
}
for (int i = 0; i < 2 * ENTRY_COUNT; i++) {
cache.remove(i);
}
assertEquals(ENTRY_COUNT, stats.getCacheRemovals());
}
use of com.hazelcast.cache.CacheStatistics in project hazelcast by hazelcast.
the class CacheStatsTest method testGettingStatistics.
@Test
public void testGettingStatistics() {
ICache<Integer, String> cache = createCache();
CacheStatistics stats = cache.getLocalCacheStatistics();
assertNotNull(stats);
}
Aggregations