Search in sources :

Example 41 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class MapServiceContextImpl method removeRecordStoresFromPartitionMatchingWith.

@Override
public void removeRecordStoresFromPartitionMatchingWith(Predicate<RecordStore> predicate, int partitionId, boolean onShutdown, boolean onRecordStoreDestroy) {
    PartitionContainer container = partitionContainers[partitionId];
    if (container == null) {
        return;
    }
    Iterator<RecordStore> partitionIterator = container.getMaps().values().iterator();
    while (partitionIterator.hasNext()) {
        RecordStore partition = partitionIterator.next();
        if (predicate.test(partition)) {
            partition.beforeOperation();
            try {
                partition.clearPartition(onShutdown, onRecordStoreDestroy);
            } finally {
                partition.afterOperation();
            }
            partitionIterator.remove();
        }
    }
}
Also used : DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore)

Example 42 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class MapClearExpiredRecordsTask method equalizeBackupSizeWithPrimary.

protected void equalizeBackupSizeWithPrimary(PartitionContainer container) {
    if (!canPrimaryDriveExpiration()) {
        return;
    }
    ConcurrentMap<String, RecordStore> maps = container.getMaps();
    for (RecordStore recordStore : maps.values()) {
        int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount();
        toBackupSender.invokeBackupExpiryOperation(Collections.emptyList(), totalBackupCount, recordStore.getPartitionId(), recordStore);
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore)

Example 43 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class MapClearExpiredRecordsTask method notHaveAnyExpirableRecord.

/**
 * Here we check if that partition has any expirable record or not,
 * if no expirable record exists in that partition no need to fire
 * an expiration operation.
 *
 * @param partitionContainer corresponding partition container.
 * @return <code>true</code> if no expirable record in that
 * partition <code>false</code> otherwise.
 */
@Override
protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) {
    boolean notExist = true;
    final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps();
    for (RecordStore store : maps.values()) {
        if (store.isExpirable()) {
            notExist = false;
            break;
        }
    }
    return notExist;
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore)

Example 44 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class PartitionContainer method createRecordStore.

private RecordStore createRecordStore(String name) {
    MapServiceContext serviceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = serviceContext.getMapContainer(name);
    MapConfig mapConfig = mapContainer.getMapConfig();
    NodeEngine nodeEngine = serviceContext.getNodeEngine();
    IPartitionService ps = nodeEngine.getPartitionService();
    OperationService opService = nodeEngine.getOperationService();
    ExecutionService execService = nodeEngine.getExecutionService();
    HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
    MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData(), serviceContext.getNodeWideLoadedKeyLimiter());
    keyLoader.setMaxBatch(hazelcastProperties.getInteger(ClusterProperty.MAP_LOAD_CHUNK_SIZE));
    keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getEvictionConfig()));
    keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
    keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
    if (!mapContainer.isGlobalIndexEnabled()) {
        Indexes indexesForMap = mapContainer.createIndexes(false);
        indexes.putIfAbsent(name, indexesForMap);
    }
    RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
    recordStore.init();
    return recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Indexes(com.hazelcast.query.impl.Indexes)

Example 45 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore 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

RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)66 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)21 MapService (com.hazelcast.map.impl.MapService)20 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)10 Data (com.hazelcast.internal.serialization.Data)9 MapContainer (com.hazelcast.map.impl.MapContainer)8 DefaultRecordStore (com.hazelcast.map.impl.recordstore.DefaultRecordStore)8 Indexes (com.hazelcast.query.impl.Indexes)8 Map (java.util.Map)8 NodeEngine (com.hazelcast.spi.impl.NodeEngine)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 MapConfig (com.hazelcast.config.MapConfig)6 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6 Record (com.hazelcast.map.impl.record.Record)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 ArrayList (java.util.ArrayList)6