Search in sources :

Example 1 with IndexesStats

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

the class LocalMapStatsProvider method addIndexStats.

private void addIndexStats(String mapName, LocalMapStatsImpl localMapStats) {
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Indexes globalIndexes = mapContainer.getIndexes();
    Map<String, OnDemandIndexStats> freshStats = null;
    if (globalIndexes != null) {
        assert globalIndexes.isGlobal();
        localMapStats.setQueryCount(globalIndexes.getIndexesStats().getQueryCount());
        localMapStats.setIndexedQueryCount(globalIndexes.getIndexesStats().getIndexedQueryCount());
        freshStats = aggregateFreshIndexStats(globalIndexes.getIndexes(), null);
        finalizeFreshIndexStats(freshStats);
    } else {
        long queryCount = 0;
        long indexedQueryCount = 0;
        PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
        for (PartitionContainer partitionContainer : partitionContainers) {
            IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
            if (!partition.isLocal()) {
                continue;
            }
            Indexes partitionIndexes = partitionContainer.getIndexes().get(mapName);
            if (partitionIndexes == null) {
                continue;
            }
            assert !partitionIndexes.isGlobal();
            IndexesStats indexesStats = partitionIndexes.getIndexesStats();
            // Partitions may have different query stats due to migrations
            // (partition stats is not preserved while migrating) and/or
            // partition-specific queries, map query stats is estimated as a
            // maximum among partitions.
            queryCount = Math.max(queryCount, indexesStats.getQueryCount());
            indexedQueryCount = Math.max(indexedQueryCount, indexesStats.getIndexedQueryCount());
            freshStats = aggregateFreshIndexStats(partitionIndexes.getIndexes(), freshStats);
        }
        localMapStats.setQueryCount(queryCount);
        localMapStats.setIndexedQueryCount(indexedQueryCount);
        finalizeFreshIndexStats(freshStats);
    }
    localMapStats.updateIndexStats(freshStats);
}
Also used : OnDemandIndexStats(com.hazelcast.internal.monitor.impl.OnDemandIndexStats) IndexesStats(com.hazelcast.internal.monitor.impl.IndexesStats) Indexes(com.hazelcast.query.impl.Indexes) IPartition(com.hazelcast.internal.partition.IPartition)

Aggregations

IndexesStats (com.hazelcast.internal.monitor.impl.IndexesStats)1 OnDemandIndexStats (com.hazelcast.internal.monitor.impl.OnDemandIndexStats)1 IPartition (com.hazelcast.internal.partition.IPartition)1 Indexes (com.hazelcast.query.impl.Indexes)1