use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.
the class LocalMapStatsProvider method createAllLocalMapStats.
public Map<String, LocalMapStats> createAllLocalMapStats() {
Map statsPerMap = new HashMap();
PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
for (int i = 0; i < partitionContainers.length; i++) {
PartitionContainer partitionContainer = partitionContainers[i];
Collection<RecordStore> allRecordStores = partitionContainer.getAllRecordStores();
for (RecordStore recordStore : allRecordStores) {
if (!isStatsCalculationEnabledFor(recordStore)) {
continue;
}
IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId(), false);
if (partition.isLocal()) {
addStatsOfPrimaryReplica(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
} else {
addStatsOfBackupReplica(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
}
}
}
// reuse same HashMap to return calculated LocalMapStats.
for (Object object : statsPerMap.entrySet()) {
Map.Entry entry = (Map.Entry) object;
String mapName = ((String) entry.getKey());
LocalMapStatsImpl existingStats = getLocalMapStatsImpl(mapName);
LocalMapOnDemandCalculatedStats onDemand = ((LocalMapOnDemandCalculatedStats) entry.getValue());
addNearCacheStats(mapName, existingStats, onDemand);
addIndexStats(mapName, existingStats);
addStructureStats(mapName, onDemand);
LocalMapStatsImpl updatedStats = onDemand.updateAndGet(existingStats);
entry.setValue(updatedStats);
}
addStatsOfNoDataIncludedMaps(statsPerMap);
return statsPerMap;
}
use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.
the class MultiMapClearMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
int totalAffectedEntries = 0;
for (Object affectedEntries : map.values()) {
totalAffectedEntries += (Integer) affectedEntries;
}
updateStats(LocalMapStatsImpl::incrementOtherOperations);
final MultiMapService service = getService(MultiMapService.SERVICE_NAME);
service.publishMultiMapEvent(parameters, EntryEventType.CLEAR_ALL, totalAffectedEntries);
return null;
}
use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.
the class MultiMapValuesMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
List<Data> list = new ArrayList<>();
for (Object obj : map.values()) {
if (obj == null) {
continue;
}
MultiMapResponse response = (MultiMapResponse) obj;
Collection<MultiMapRecord> coll = response.getCollection();
if (coll == null) {
continue;
}
for (MultiMapRecord record : coll) {
list.add(serializationService.toData(record.getObject()));
}
}
updateStats(LocalMapStatsImpl::incrementOtherOperations);
return list;
}
use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.
the class PhoneHomeTest method testMapGetLatencyWithoutMapStore.
@Test
public void testMapGetLatencyWithoutMapStore() {
Map<String, String> parameters;
parameters = phoneHome.phoneHome(true);
assertEquals(parameters.get(PhoneHomeMetrics.AVERAGE_GET_LATENCY_OF_MAPS_WITHOUT_MAPSTORE.getRequestParameterName()), "-1");
IMap<Object, Object> iMap = node.hazelcastInstance.getMap("hazelcast");
LocalMapStatsImpl localMapStats = (LocalMapStatsImpl) iMap.getLocalMapStats();
localMapStats.incrementGetLatencyNanos(2000000000L);
parameters = phoneHome.phoneHome(true);
assertEquals(parameters.get(PhoneHomeMetrics.AVERAGE_GET_LATENCY_OF_MAPS_WITHOUT_MAPSTORE.getRequestParameterName()), String.valueOf(2000));
localMapStats.incrementGetLatencyNanos(2000000000L);
parameters = phoneHome.phoneHome(true);
assertEquals(parameters.get(PhoneHomeMetrics.AVERAGE_GET_LATENCY_OF_MAPS_WITHOUT_MAPSTORE.getRequestParameterName()), String.valueOf(2000));
}
Aggregations