Search in sources :

Example 1 with LocalRecordStoreStats

use of com.hazelcast.internal.monitor.LocalRecordStoreStats in project hazelcast by hazelcast.

the class LocalMapStatsProvider method addStatsOfPrimaryReplica.

private static void addStatsOfPrimaryReplica(RecordStore recordStore, LocalMapOnDemandCalculatedStats onDemandStats) {
    LocalRecordStoreStats stats = recordStore.getLocalRecordStoreStats();
    onDemandStats.incrementHits(stats.getHits());
    onDemandStats.incrementDirtyEntryCount(recordStore.getMapDataStore().notFinishedOperationsCount());
    onDemandStats.incrementOwnedEntryMemoryCost(recordStore.getOwnedEntryCost());
    if (NATIVE != recordStore.getMapContainer().getMapConfig().getInMemoryFormat()) {
        onDemandStats.incrementHeapCost(recordStore.getOwnedEntryCost());
    }
    onDemandStats.incrementOwnedEntryCount(recordStore.size());
    onDemandStats.setLastAccessTime(stats.getLastAccessTime());
    onDemandStats.setLastUpdateTime(stats.getLastUpdateTime());
    onDemandStats.setBackupCount(recordStore.getMapContainer().getMapConfig().getTotalBackupCount());
    // we need to update the locked entry count here whether or not the map is empty
    // keys that are not contained by a map can be locked
    onDemandStats.incrementLockedEntryCount(recordStore.getLockedEntryCount());
}
Also used : LocalRecordStoreStats(com.hazelcast.internal.monitor.LocalRecordStoreStats)

Example 2 with LocalRecordStoreStats

use of com.hazelcast.internal.monitor.LocalRecordStoreStats in project hazelcast by hazelcast.

the class MapReplicationStateHolder method applyState.

@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:methodlength", "checkstyle:cyclomaticcomplexity", "checkstyle:nestedifdepth" })
void applyState() {
    ThreadUtil.assertRunningOnPartitionThread();
    applyIndexesState();
    if (!isNullOrEmpty(data)) {
        for (Map.Entry<String, List> dataEntry : data.entrySet()) {
            String mapName = dataEntry.getKey();
            List keyRecordExpiry = dataEntry.getValue();
            RecordStore recordStore = operation.getRecordStore(mapName);
            recordStore.beforeOperation();
            try {
                initializeRecordStore(mapName, recordStore);
                recordStore.setPreMigrationLoadedStatus(loaded.get(mapName));
                MapContainer mapContainer = recordStore.getMapContainer();
                PartitionContainer partitionContainer = recordStore.getMapContainer().getMapServiceContext().getPartitionContainer(operation.getPartitionId());
                for (Map.Entry<String, IndexConfig> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) {
                    Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
                    indexes.addOrGetIndex(indexDefinition.getValue());
                }
                final Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
                final boolean populateIndexes = indexesMustBePopulated(indexes, operation);
                InternalIndex[] indexesSnapshot = null;
                if (populateIndexes) {
                    // defensively clear possible stale leftovers in non-global indexes from
                    // the previous failed promotion attempt
                    indexesSnapshot = indexes.getIndexes();
                    Indexes.beginPartitionUpdate(indexesSnapshot);
                    indexes.clearAll();
                }
                long nowInMillis = Clock.currentTimeMillis();
                forEachReplicatedRecord(keyRecordExpiry, mapContainer, recordStore, populateIndexes, nowInMillis);
                if (populateIndexes) {
                    Indexes.markPartitionAsIndexed(partitionContainer.getPartitionId(), indexesSnapshot);
                }
            } finally {
                recordStore.afterOperation();
            }
        }
    }
    for (Map.Entry<String, LocalRecordStoreStats> statsEntry : recordStoreStatsPerMapName.entrySet()) {
        String mapName = statsEntry.getKey();
        LocalRecordStoreStats stats = statsEntry.getValue();
        RecordStore recordStore = operation.getRecordStore(mapName);
        recordStore.setStats(stats);
    }
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Indexes(com.hazelcast.query.impl.Indexes) MapContainer(com.hazelcast.map.impl.MapContainer) LocalRecordStoreStats(com.hazelcast.internal.monitor.LocalRecordStoreStats) InternalIndex(com.hazelcast.query.impl.InternalIndex) IndexConfig(com.hazelcast.config.IndexConfig) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

LocalRecordStoreStats (com.hazelcast.internal.monitor.LocalRecordStoreStats)2 IndexConfig (com.hazelcast.config.IndexConfig)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)1 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)1 Indexes (com.hazelcast.query.impl.Indexes)1 InternalIndex (com.hazelcast.query.impl.InternalIndex)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1