Search in sources :

Example 71 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class WriteBehindStateHolder method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    int size = in.readInt();
    delayedEntries = new HashMap<String, List<DelayedEntry>>(size);
    for (int i = 0; i < size; i++) {
        String mapName = in.readUTF();
        int listSize = in.readInt();
        List<DelayedEntry> delayedEntriesList = new ArrayList<DelayedEntry>(listSize);
        for (int j = 0; j < listSize; j++) {
            Data key = in.readData();
            Data value = in.readData();
            long storeTime = in.readLong();
            int partitionId = in.readInt();
            long sequence = in.readLong();
            DelayedEntry<Data, Data> entry = DelayedEntries.createDefault(key, value, storeTime, partitionId);
            entry.setSequence(sequence);
            delayedEntriesList.add(entry);
        }
        delayedEntries.put(mapName, delayedEntriesList);
    }
    int expectedSize = in.readInt();
    flushSequences = new HashMap<String, Queue<WriteBehindStore.Sequence>>(expectedSize);
    for (int i = 0; i < expectedSize; i++) {
        String mapName = in.readUTF();
        int setSize = in.readInt();
        Queue<WriteBehindStore.Sequence> queue = new ArrayDeque<WriteBehindStore.Sequence>(setSize);
        for (int j = 0; j < setSize; j++) {
            queue.add(new WriteBehindStore.Sequence(in.readLong(), in.readBoolean()));
        }
        flushSequences.put(mapName, queue);
    }
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) ArrayDeque(java.util.ArrayDeque) ArrayList(java.util.ArrayList) List(java.util.List) WriteBehindQueue(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue) Queue(java.util.Queue)

Example 72 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class PartitionWideEntryBackupOperation method run.

@Override
public void run() {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    Iterator<Record> iterator = recordStore.iterator(now, true);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data dataKey = record.getKey();
        Object oldValue = record.getValue();
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        if (!applyPredicate(dataKey, value)) {
            continue;
        }
        Map.Entry entry = createMapEntry(dataKey, value);
        processBackup(entry);
        if (noOp(entry, oldValue)) {
            continue;
        }
        if (entryRemovedBackup(entry, dataKey)) {
            continue;
        }
        entryAddedOrUpdatedBackup(entry, dataKey);
        evict(dataKey);
    }
    publishWanReplicationEventBackups();
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 73 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class PartitionWideEntryOperation method run.

@Override
public void run() {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    responses = new MapEntries(recordStore.size());
    Iterator<Record> iterator = recordStore.iterator(now, false);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data dataKey = record.getKey();
        Object oldValue = record.getValue();
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        if (!applyPredicate(dataKey, value)) {
            continue;
        }
        Map.Entry entry = createMapEntry(dataKey, value);
        Data response = process(entry);
        if (response != null) {
            responses.add(dataKey, response);
        }
        // first call noOp, other if checks below depends on it.
        if (noOp(entry, oldValue, now)) {
            continue;
        }
        if (entryRemoved(entry, dataKey, oldValue, now)) {
            continue;
        }
        entryAddedOrUpdated(entry, dataKey, oldValue, now);
        evict(dataKey);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) SerializationService(com.hazelcast.spi.serialization.SerializationService) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 74 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxyImpl method executeOnEntries.

@Override
public Map<K, Object> executeOnEntries(EntryProcessor entryProcessor, Predicate predicate) {
    List<Data> result = new ArrayList<Data>();
    executeOnEntriesInternal(entryProcessor, predicate, result);
    if (result.isEmpty()) {
        return emptyMap();
    }
    Map<K, Object> resultingMap = MapUtil.createHashMap(result.size() / 2);
    for (int i = 0; i < result.size(); ) {
        Data key = result.get(i++);
        Data value = result.get(i++);
        resultingMap.put((K) toObject(key), toObject(value));
    }
    return resultingMap;
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 75 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxyImpl method containsKey.

@Override
public boolean containsKey(Object k) {
    checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
    Data key = toData(k, partitionStrategy);
    return containsKeyInternal(key);
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Aggregations

Data (com.hazelcast.nio.serialization.Data)773 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)140 Test (org.junit.Test)121 QuickTest (com.hazelcast.test.annotation.QuickTest)118 ParallelTest (com.hazelcast.test.annotation.ParallelTest)108 ArrayList (java.util.ArrayList)81 Map (java.util.Map)64 SerializationService (com.hazelcast.spi.serialization.SerializationService)54 HashMap (java.util.HashMap)54 NodeEngine (com.hazelcast.spi.NodeEngine)50 HashSet (java.util.HashSet)39 Address (com.hazelcast.nio.Address)28 AbstractMap (java.util.AbstractMap)28 Record (com.hazelcast.map.impl.record.Record)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 HeapData (com.hazelcast.internal.serialization.impl.HeapData)26 List (java.util.List)20 Future (java.util.concurrent.Future)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 Operation (com.hazelcast.spi.Operation)18