Search in sources :

Example 11 with LocalMapStatsImpl

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;
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) HashMap(java.util.HashMap) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) DistributedObject(com.hazelcast.core.DistributedObject) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) IPartition(com.hazelcast.internal.partition.IPartition)

Example 12 with LocalMapStatsImpl

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;
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) MultiMapService(com.hazelcast.multimap.impl.MultiMapService)

Example 13 with LocalMapStatsImpl

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;
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.internal.serialization.Data)

Example 14 with LocalMapStatsImpl

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));
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) DistributedObject(com.hazelcast.core.DistributedObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LocalMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalMapStatsImpl)14 QuickTest (com.hazelcast.test.annotation.QuickTest)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 DistributedObject (com.hazelcast.core.DistributedObject)3 Data (com.hazelcast.internal.serialization.Data)2 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 InMemoryFormat (com.hazelcast.config.InMemoryFormat)1 MapConfig (com.hazelcast.config.MapConfig)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 LocalIndexStatsImpl (com.hazelcast.internal.monitor.impl.LocalIndexStatsImpl)1 PerIndexStats (com.hazelcast.internal.monitor.impl.PerIndexStats)1 IPartition (com.hazelcast.internal.partition.IPartition)1 IMap (com.hazelcast.map.IMap)1 LocalMapStats (com.hazelcast.map.LocalMapStats)1 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)1 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)1