Search in sources :

Example 1 with WriteBehindQueue

use of com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue 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)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 WriteBehindQueue (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue)1 WriteBehindStore (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)1 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)1 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Queue (java.util.Queue)1