Search in sources :

Example 6 with RecordStore

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

the class StoreWorker method notifyFlush.

private void notifyFlush() {
    for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
        RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
        if (recordStore != null) {
            WriteBehindStore mapDataStore = ((WriteBehindStore) recordStore.getMapDataStore());
            mapDataStore.notifyFlush();
        }
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore)

Example 7 with RecordStore

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

the class WriteBehindStateHolder method applyState.

void applyState() {
    for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) {
        String mapName = entry.getKey();
        RecordStore recordStore = mapReplicationOperation.getRecordStore(mapName);
        WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
        mapDataStore.reset();
        mapDataStore.setFlushSequences(flushSequences.get(mapName));
        Collection<DelayedEntry> replicatedEntries = entry.getValue();
        for (DelayedEntry delayedEntry : replicatedEntries) {
            mapDataStore.add(delayedEntry);
            mapDataStore.setSequence(delayedEntry.getSequence());
        }
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) ArrayList(java.util.ArrayList) List(java.util.List) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) HashMap(java.util.HashMap) Map(java.util.Map) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 8 with RecordStore

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

the class WriteBehindStateHolder method prepare.

void prepare(PartitionContainer container, int replicaIndex) {
    int size = container.getMaps().size();
    flushSequences = new HashMap<String, Queue<WriteBehindStore.Sequence>>(size);
    delayedEntries = new HashMap<String, List<DelayedEntry>>(size);
    for (Map.Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
        RecordStore recordStore = entry.getValue();
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex || !mapContainer.getMapStoreContext().isWriteBehindMapStoreEnabled()) {
            continue;
        }
        WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
        WriteBehindQueue<DelayedEntry> writeBehindQueue = mapDataStore.getWriteBehindQueue();
        List<DelayedEntry> entries = writeBehindQueue.asList();
        if (entries == null || entries.isEmpty()) {
            continue;
        }
        String mapName = entry.getKey();
        delayedEntries.put(mapName, entries);
        flushSequences.put(mapName, new ArrayDeque<WriteBehindStore.Sequence>(mapDataStore.getFlushSequences()));
    }
}
Also used : DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) MapContainer(com.hazelcast.map.impl.MapContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) ArrayList(java.util.ArrayList) List(java.util.List) MapConfig(com.hazelcast.config.MapConfig) WriteBehindQueue(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue) Queue(java.util.Queue) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with RecordStore

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

the class MapKeyValueSource method open.

@Override
public boolean open(NodeEngine nodeEngine) {
    NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
    IPartitionService ps = nei.getPartitionService();
    MapService mapService = nei.getService(MapService.SERVICE_NAME);
    ss = nei.getSerializationService();
    Address partitionOwner = ps.getPartitionOwner(partitionId);
    if (partitionOwner == null) {
        return false;
    }
    RecordStore recordStore = mapService.getMapServiceContext().getRecordStore(partitionId, mapName);
    iterator = recordStore.iterator();
    return true;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService)

Example 10 with RecordStore

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

the class MapContainerCreationUponDestroyStressTest method assertRecordStoresSharesSameMapContainerInstance.

private void assertRecordStoresSharesSameMapContainerInstance(IMap<Long, Long> map) {
    String mapName = map.getName();
    MapContainer expectedMapContainer = getMapContainer(map);
    for (int i = 0; i < PARTITION_COUNT; i++) {
        PartitionContainer partitionContainer = getMapServiceContext(map).getPartitionContainer(i);
        RecordStore recordStore = partitionContainer.getMaps().get(mapName);
        if (recordStore == null) {
            continue;
        }
        assertEquals(expectedMapContainer, recordStore.getMapContainer());
    }
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapContainer(com.hazelcast.map.impl.MapContainer)

Aggregations

RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)31 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)12 MapService (com.hazelcast.map.impl.MapService)8 Data (com.hazelcast.nio.serialization.Data)7 Map (java.util.Map)7 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)6 HashMap (java.util.HashMap)6 IPartitionService (com.hazelcast.spi.partition.IPartitionService)5 ArrayList (java.util.ArrayList)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 SimpleEntryView (com.hazelcast.map.impl.SimpleEntryView)4 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)4 Record (com.hazelcast.map.impl.record.Record)4 DefaultRecordStore (com.hazelcast.map.impl.recordstore.DefaultRecordStore)4 MapMergePolicy (com.hazelcast.map.merge.MapMergePolicy)4 PutIfAbsentMapMergePolicy (com.hazelcast.map.merge.PutIfAbsentMapMergePolicy)4 NodeEngine (com.hazelcast.spi.NodeEngine)4 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4