Search in sources :

Example 11 with CacheStatistics

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());
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 with CacheStatistics

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);
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with CacheStatistics

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());
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 14 with CacheStatistics

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());
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 15 with CacheStatistics

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);
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

CacheStatistics (com.hazelcast.cache.CacheStatistics)22 ParallelTest (com.hazelcast.test.annotation.ParallelTest)19 QuickTest (com.hazelcast.test.annotation.QuickTest)19 Test (org.junit.Test)19 CacheConfig (com.hazelcast.config.CacheConfig)3 JsonObject (com.eclipsesource.json.JsonObject)1 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CacheStatsTest (com.hazelcast.cache.stats.CacheStatsTest)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)1 QueueService (com.hazelcast.collection.impl.queue.QueueService)1 Config (com.hazelcast.config.Config)1 GroupConfig (com.hazelcast.config.GroupConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 DistributedExecutorService (com.hazelcast.executor.impl.DistributedExecutorService)1 MapService (com.hazelcast.map.impl.MapService)1 LocalWanStats (com.hazelcast.monitor.LocalWanStats)1 MultiMapService (com.hazelcast.multimap.impl.MultiMapService)1 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)1