Search in sources :

Example 6 with LocalMapStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.

the class PhoneHomeIntegrationTest method testMapLatenciesWithoutMapStore.

@Test
public void testMapLatenciesWithoutMapStore() {
    IMap<Object, Object> iMap1 = node.hazelcastInstance.getMap("hazelcast");
    LocalMapStatsImpl localMapStats1 = (LocalMapStatsImpl) iMap1.getLocalMapStats();
    IMap<Object, Object> iMap2 = node.hazelcastInstance.getMap("phonehome");
    LocalMapStatsImpl localMapStats2 = (LocalMapStatsImpl) iMap2.getLocalMapStats();
    localMapStats1.incrementPutLatencyNanos(2000000000L);
    localMapStats1.incrementPutLatencyNanos(1000000000L);
    localMapStats2.incrementPutLatencyNanos(2000000000L);
    localMapStats1.incrementGetLatencyNanos(1000000000L);
    localMapStats2.incrementGetLatencyNanos(1000000000L);
    phoneHome.phoneHome(false);
    verify(1, postRequestedFor(urlPathEqualTo("/ping")).withRequestBody(containingParam("mpptla", "1666")).withRequestBody(containingParam("mpgtla", "1000")));
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with LocalMapStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.

the class PhoneHomeIntegrationTest method testMapLatenciesWithMapStore.

@Test
public void testMapLatenciesWithMapStore() {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new DelayMapStore());
    IMap<String, String> iMap = node.hazelcastInstance.getMap("hazelcast");
    node.getConfig().getMapConfig("hazelcast").setMapStoreConfig(mapStoreConfig);
    iMap.put("key1", "hazelcast");
    iMap.put("key2", "phonehome");
    iMap.get("key3");
    LocalMapStatsImpl mapStats = (LocalMapStatsImpl) iMap.getLocalMapStats();
    long totalGetLatency = mapStats.getTotalGetLatency();
    long totalPutLatency = mapStats.getTotalPutLatency();
    long totalGetOperationCount = mapStats.getGetOperationCount();
    long totalPutOperationCount = mapStats.getPutOperationCount();
    phoneHome.phoneHome(false);
    verify(1, postRequestedFor(urlPathEqualTo("/ping")).withRequestBody(containingParam("mpptlams", String.valueOf(totalPutLatency / totalPutOperationCount))).withRequestBody(containingParam("mpgtlams", String.valueOf(totalGetLatency / totalGetOperationCount))));
    assertGreaterOrEquals("mpptlams", totalPutLatency / totalPutOperationCount, 200);
    assertGreaterOrEquals("mpgtlams", totalGetLatency / totalGetOperationCount, 200);
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with LocalMapStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.

the class ClientIndexStatsTest method combineStats.

private static LocalMapStats combineStats(IMap map1, IMap map2) {
    LocalMapStats stats1 = map1.getLocalMapStats();
    LocalMapStats stats2 = map2.getLocalMapStats();
    List<Indexes> allIndexes = new ArrayList<Indexes>();
    allIndexes.addAll(getAllIndexes(map1));
    allIndexes.addAll(getAllIndexes(map2));
    LocalMapStatsImpl combinedStats = new LocalMapStatsImpl();
    assertEquals(stats1.getQueryCount(), stats2.getQueryCount());
    combinedStats.setQueryCount(stats1.getQueryCount());
    assertEquals(stats1.getIndexedQueryCount(), stats2.getIndexedQueryCount());
    combinedStats.setIndexedQueryCount(stats1.getIndexedQueryCount());
    assertEquals(stats1.getIndexStats().size(), stats2.getIndexStats().size());
    Map<String, LocalIndexStatsImpl> combinedIndexStatsMap = new HashMap<String, LocalIndexStatsImpl>();
    for (Map.Entry<String, LocalIndexStats> indexEntry : stats1.getIndexStats().entrySet()) {
        LocalIndexStats indexStats1 = indexEntry.getValue();
        LocalIndexStats indexStats2 = stats2.getIndexStats().get(indexEntry.getKey());
        assertNotNull(indexStats2);
        LocalIndexStatsImpl combinedIndexStats = new LocalIndexStatsImpl();
        assertEquals(indexStats1.getHitCount(), indexStats2.getHitCount());
        combinedIndexStats.setHitCount(indexStats1.getHitCount());
        assertEquals(indexStats1.getQueryCount(), indexStats2.getQueryCount());
        combinedIndexStats.setQueryCount(indexStats1.getQueryCount());
        combinedIndexStats.setAverageHitLatency((indexStats1.getAverageHitLatency() + indexStats2.getAverageHitLatency()) / 2);
        long totalHitCount = 0;
        double totalNormalizedHitCardinality = 0.0;
        for (Indexes indexes : allIndexes) {
            PerIndexStats perIndexStats = indexes.getIndex(indexEntry.getKey()).getPerIndexStats();
            totalHitCount += perIndexStats.getHitCount();
            totalNormalizedHitCardinality += perIndexStats.getTotalNormalizedHitCardinality();
        }
        combinedIndexStats.setAverageHitSelectivity(totalHitCount == 0 ? 0.0 : 1.0 - totalNormalizedHitCardinality / totalHitCount);
        combinedIndexStats.setInsertCount(indexStats1.getInsertCount() + indexStats2.getInsertCount());
        combinedIndexStats.setTotalInsertLatency(indexStats1.getTotalInsertLatency() + indexStats2.getTotalInsertLatency());
        combinedIndexStats.setUpdateCount(indexStats1.getUpdateCount() + indexStats2.getUpdateCount());
        combinedIndexStats.setTotalUpdateLatency(indexStats1.getTotalUpdateLatency() + indexStats2.getTotalUpdateLatency());
        combinedIndexStats.setRemoveCount(indexStats1.getRemoveCount() + indexStats2.getRemoveCount());
        combinedIndexStats.setTotalRemoveLatency(indexStats1.getTotalRemoveLatency() + indexStats2.getTotalRemoveLatency());
        combinedIndexStats.setMemoryCost(indexStats1.getMemoryCost() + indexStats2.getMemoryCost());
        combinedIndexStatsMap.put(indexEntry.getKey(), combinedIndexStats);
    }
    combinedStats.setIndexStats(combinedIndexStatsMap);
    return combinedStats;
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LocalIndexStatsImpl(com.hazelcast.internal.monitor.impl.LocalIndexStatsImpl) Indexes(com.hazelcast.query.impl.Indexes) Accessors.getAllIndexes(com.hazelcast.test.Accessors.getAllIndexes) LocalIndexStats(com.hazelcast.query.LocalIndexStats) PerIndexStats(com.hazelcast.internal.monitor.impl.PerIndexStats) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.map.IMap)

Example 9 with LocalMapStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.

the class LocalMapStatsUtil method incrementOtherOperationsCount.

/**
 * Increments other operations count statistic in local map statistics.
 * @param service
 * @param mapName
 */
public static void incrementOtherOperationsCount(MapService service, String mapName) {
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    if (mapContainer.getMapConfig().isStatisticsEnabled()) {
        LocalMapStatsImpl localMapStats = mapServiceContext.getLocalMapStatsProvider().getLocalMapStatsImpl(mapName);
        localMapStats.incrementOtherOperations();
    }
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl)

Example 10 with LocalMapStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalMapStatsImpl in project hazelcast by hazelcast.

the class LocalMapStatsProvider method createLocalMapStatsImpl.

private LocalMapStatsImpl createLocalMapStatsImpl(String mapName) {
    // intentionally not using nodeEngine.getConfig().getMapConfig(mapName)
    // since that breaks TestFullApplicationContext#testMapConfig()
    MapConfig mapConfig = nodeEngine.getConfig().getMapConfigs().get(mapName);
    InMemoryFormat inMemoryFormat;
    if (mapConfig == null) {
        inMemoryFormat = InMemoryFormat.BINARY;
    } else {
        inMemoryFormat = mapConfig.getInMemoryFormat();
    }
    return new LocalMapStatsImpl(inMemoryFormat == OBJECT);
}
Also used : LocalMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMapStatsImpl) MapConfig(com.hazelcast.config.MapConfig) InMemoryFormat(com.hazelcast.config.InMemoryFormat)

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