Search in sources :

Example 1 with UUIDSerializationUtil.readUUID

use of com.hazelcast.internal.util.UUIDSerializationUtil.readUUID in project hazelcast by hazelcast.

the class MapChunk method readWriteBehindState.

private void readWriteBehindState(ObjectDataInput in) throws IOException {
    hasWriteBehindState = in.readBoolean();
    if (!hasWriteBehindState) {
        return;
    }
    // read delayed entries
    int listSize = in.readInt();
    delayedEntriesList = new ArrayList<>(listSize);
    for (int j = 0; j < listSize; j++) {
        Data key = IOUtil.readData(in);
        Data value = IOUtil.readData(in);
        long expirationTime = in.readLong();
        long storeTime = in.readLong();
        int partitionId = in.readInt();
        long sequence = in.readLong();
        UUID txnId = UUIDSerializationUtil.readUUID(in);
        DelayedEntry<Data, Data> entry = newAddedDelayedEntry(key, value, expirationTime, storeTime, partitionId, txnId);
        entry.setSequence(sequence);
        delayedEntriesList.add(entry);
    }
    // read sequences
    int setSize = in.readInt();
    sequences = new ArrayDeque<>(setSize);
    for (int j = 0; j < setSize; j++) {
        sequences.add(new WriteBehindStore.Sequence(in.readLong(), in.readBoolean()));
    }
    // read txn reservations
    int numOfCounters = in.readInt();
    counterByTxnId = createHashMap(numOfCounters);
    for (int j = 0; j < numOfCounters; j++) {
        counterByTxnId.put(readUUID(in), in.readLong());
    }
}
Also used : Data(com.hazelcast.internal.serialization.Data) UUIDSerializationUtil.readUUID(com.hazelcast.internal.util.UUIDSerializationUtil.readUUID) UUID(java.util.UUID) UUIDSerializationUtil.writeUUID(com.hazelcast.internal.util.UUIDSerializationUtil.writeUUID) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 2 with UUIDSerializationUtil.readUUID

use of com.hazelcast.internal.util.UUIDSerializationUtil.readUUID in project hazelcast by hazelcast.

the class WriteBehindStateHolder method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    int size = in.readInt();
    delayedEntries = createHashMap(size);
    for (int i = 0; i < size; i++) {
        String mapName = in.readString();
        int listSize = in.readInt();
        List<DelayedEntry> delayedEntriesList = new ArrayList<>(listSize);
        for (int j = 0; j < listSize; j++) {
            Data key = IOUtil.readData(in);
            Data value = IOUtil.readData(in);
            long expirationTime = in.readLong();
            long storeTime = in.readLong();
            int partitionId = in.readInt();
            long sequence = in.readLong();
            UUID txnId = UUIDSerializationUtil.readUUID(in);
            DelayedEntry<Data, Data> entry = newAddedDelayedEntry(key, value, expirationTime, storeTime, partitionId, txnId);
            entry.setSequence(sequence);
            delayedEntriesList.add(entry);
        }
        delayedEntries.put(mapName, delayedEntriesList);
    }
    int expectedSize = in.readInt();
    flushSequences = createHashMap(expectedSize);
    for (int i = 0; i < expectedSize; i++) {
        String mapName = in.readString();
        int setSize = in.readInt();
        Queue<WriteBehindStore.Sequence> queue = new ArrayDeque<>(setSize);
        for (int j = 0; j < setSize; j++) {
            queue.add(new WriteBehindStore.Sequence(in.readLong(), in.readBoolean()));
        }
        flushSequences.put(mapName, queue);
    }
    int mapCount = in.readInt();
    reservationsByTxnIdPerMap = mapCount == 0 ? Collections.emptyMap() : new HashMap<>(mapCount);
    for (int i = 0; i < mapCount; i++) {
        String mapName = in.readString();
        int numOfCounters = in.readInt();
        Map<UUID, Long> counterByTxnId = createHashMap(numOfCounters);
        for (int j = 0; j < numOfCounters; j++) {
            counterByTxnId.put(readUUID(in), in.readLong());
        }
        reservationsByTxnIdPerMap.put(mapName, counterByTxnId);
    }
}
Also used : HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ArrayList(java.util.ArrayList) Data(com.hazelcast.internal.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) DelayedEntries.newAddedDelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntries.newAddedDelayedEntry) ArrayDeque(java.util.ArrayDeque) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) UUIDSerializationUtil.readUUID(com.hazelcast.internal.util.UUIDSerializationUtil.readUUID) UUIDSerializationUtil.writeUUID(com.hazelcast.internal.util.UUIDSerializationUtil.writeUUID) UUID(java.util.UUID)

Aggregations

Data (com.hazelcast.internal.serialization.Data)2 UUIDSerializationUtil.readUUID (com.hazelcast.internal.util.UUIDSerializationUtil.readUUID)2 UUIDSerializationUtil.writeUUID (com.hazelcast.internal.util.UUIDSerializationUtil.writeUUID)2 WriteBehindStore (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)2 UUID (java.util.UUID)2 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 DelayedEntries.newAddedDelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntries.newAddedDelayedEntry)1 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1