use of com.hazelcast.monitor.LocalMapStats in project spring-boot by spring-projects.
the class HazelcastCacheStatisticsProvider method getCacheStatistics.
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, HazelcastCache cache) {
DefaultCacheStatistics statistics = new DefaultCacheStatistics();
LocalMapStats mapStatistics = ((IMap<?, ?>) cache.getNativeCache()).getLocalMapStats();
statistics.setSize(mapStatistics.getOwnedEntryCount());
statistics.setGetCacheCounts(mapStatistics.getHits(), mapStatistics.getGetOperationCount() - mapStatistics.getHits());
return statistics;
}
use of com.hazelcast.monitor.LocalMapStats in project hazelcast by hazelcast.
the class LocalMapStatsTest method testLastAccessTime_updatedConcurrently.
@Test
public void testLastAccessTime_updatedConcurrently() throws InterruptedException {
final long startTime = Clock.currentTimeMillis();
final IMap<String, String> map = getMap();
final String key = "key";
map.put(key, "value");
map.put(key, "value");
final LocalMapStats localMapStats = map.getLocalMapStats();
final long lastUpdateTime = localMapStats.getLastUpdateTime();
new Thread(new Runnable() {
@Override
public void run() {
sleepAtLeastMillis(1);
map.put(key, "value2");
// causes the local stats object to update
map.getLocalMapStats();
}
}).start();
assertTrue(lastUpdateTime >= startTime);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(localMapStats.getLastUpdateTime() > lastUpdateTime);
}
});
}
use of com.hazelcast.monitor.LocalMapStats in project hazelcast by hazelcast.
the class LocalMapStatsTest method testPutAllGenerated.
@Test
public void testPutAllGenerated() throws Exception {
IMap<Integer, Integer> map = getMap();
for (int i = 0; i < 100; i++) {
Map<Integer, Integer> putMap = new HashMap<Integer, Integer>(2);
putMap.put(i, i);
putMap.put(100 + i, 100 + i);
map.putAll(putMap);
}
LocalMapStats localMapStats = map.getLocalMapStats();
assertEquals(200, localMapStats.getPutOperationCount());
}
use of com.hazelcast.monitor.LocalMapStats in project hazelcast by hazelcast.
the class LocalMapStatsTest method testPutAndHitsGenerated.
@Test
public void testPutAndHitsGenerated() throws Exception {
IMap<Integer, Integer> map = getMap();
for (int i = 0; i < 100; i++) {
map.put(i, i);
map.get(i);
}
LocalMapStats localMapStats = map.getLocalMapStats();
assertEquals(100, localMapStats.getPutOperationCount());
assertEquals(100, localMapStats.getHits());
}
use of com.hazelcast.monitor.LocalMapStats in project hazelcast by hazelcast.
the class LocalMapStatsTest method testPutAsync.
@Test
public void testPutAsync() throws Exception {
IMap<Integer, Integer> map = getMap();
for (int i = 0; i < 100; i++) {
map.putAsync(i, i);
}
final LocalMapStats localMapStats = map.getLocalMapStats();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(100, localMapStats.getPutOperationCount());
}
});
}
Aggregations