Search in sources :

Example 26 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class CoalescedWriteBehindQueue method addFirst.

@Override
public void addFirst(Collection<DelayedEntry> collection) {
    if (isEmpty(collection)) {
        return;
    }
    int expectedCapacity = map.size() + collection.size();
    Map<Data, DelayedEntry> newMap = createMapWithExpectedCapacity(expectedCapacity);
    for (DelayedEntry next : collection) {
        newMap.put((Data) next.getKey(), next);
    }
    newMap.putAll(map);
    map = newMap;
}
Also used : Data(com.hazelcast.nio.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)

Example 27 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class CyclicWriteBehindQueue method removeFirstOccurrence.

/**
     * Removes the first element of this queue instead of searching for it,
     * implementation of this method is strongly tied with {@link StoreWorker} implementation.
     *
     * @param entry element to be removed.
     * @return <code>true</code> if removed successfully, <code>false</code> otherwise
     */
@Override
public boolean removeFirstOccurrence(DelayedEntry entry) {
    DelayedEntry removedEntry = deque.pollFirst();
    if (removedEntry == null) {
        return false;
    }
    decreaseCountIndex(entry);
    return true;
}
Also used : DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)

Example 28 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class WriteBehindStateHolder method writeData.

@Override
public void writeData(ObjectDataOutput out) throws IOException {
    MapService mapService = mapReplicationOperation.getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    out.writeInt(delayedEntries.size());
    for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) {
        out.writeUTF(entry.getKey());
        List<DelayedEntry> delayedEntryList = entry.getValue();
        out.writeInt(delayedEntryList.size());
        for (DelayedEntry e : delayedEntryList) {
            Data key = mapServiceContext.toData(e.getKey());
            Data value = mapServiceContext.toData(e.getValue());
            out.writeData(key);
            out.writeData(value);
            out.writeLong(e.getStoreTime());
            out.writeInt(e.getPartitionId());
            out.writeLong(e.getSequence());
        }
    }
    out.writeInt(flushSequences.size());
    for (Map.Entry<String, Queue<WriteBehindStore.Sequence>> entry : flushSequences.entrySet()) {
        out.writeUTF(entry.getKey());
        Queue<WriteBehindStore.Sequence> queue = entry.getValue();
        out.writeInt(queue.size());
        for (WriteBehindStore.Sequence sequence : queue) {
            out.writeLong(sequence.getSequence());
            out.writeBoolean(sequence.isFullFlush());
        }
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) ArrayList(java.util.ArrayList) List(java.util.List) MapService(com.hazelcast.map.impl.MapService) HashMap(java.util.HashMap) Map(java.util.Map) WriteBehindQueue(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue) Queue(java.util.Queue)

Aggregations

DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)28 ArrayList (java.util.ArrayList)9 Data (com.hazelcast.nio.serialization.Data)7 HashMap (java.util.HashMap)6 List (java.util.List)6 WriteBehindStore (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)5 Map (java.util.Map)5 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 WriteBehindQueue (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Queue (java.util.Queue)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.Test)3 MapConfig (com.hazelcast.config.MapConfig)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 MapDataStore (com.hazelcast.map.impl.mapstore.MapDataStore)1