Search in sources :

Example 81 with Data

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

the class PutBackupOperation method publishWANReplicationEventBackup.

private void publishWANReplicationEventBackup(MapServiceContext mapServiceContext, MapEventPublisher mapEventPublisher) {
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    Record record = recordStore.getRecord(dataKey);
    if (record == null) {
        return;
    }
    final Data valueConvertedData = mapServiceContext.toData(dataValue);
    final EntryView entryView = EntryViews.createSimpleEntryView(dataKey, valueConvertedData, record);
    mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
}
Also used : EntryView(com.hazelcast.core.EntryView) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 82 with Data

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

the class MultipleEntryBackupOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeObject(backupProcessor);
    out.writeInt(keys.size());
    for (Data key : keys) {
        out.writeData(key);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 83 with Data

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

the class MultipleEntryBackupOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    backupProcessor = in.readObject();
    int size = in.readInt();
    keys = new LinkedHashSet<Data>(size);
    for (int i = 0; i < size; i++) {
        Data key = in.readData();
        keys.add(key);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 84 with Data

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

the class MultipleEntryOperation method run.

@Override
@SuppressWarnings("checkstyle:npathcomplexity")
public void run() throws Exception {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    responses = new MapEntries(keys.size());
    for (Data key : keys) {
        if (!isKeyProcessable(key)) {
            continue;
        }
        Object oldValue = recordStore.get(key, false);
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        Map.Entry entry = createMapEntry(key, value);
        if (!isEntryProcessable(entry)) {
            continue;
        }
        Data response = process(entry);
        if (response != null) {
            responses.add(key, response);
        }
        // first call noOp, other if checks below depends on it.
        if (noOp(entry, oldValue, now)) {
            continue;
        }
        if (entryRemoved(entry, key, oldValue, now)) {
            continue;
        }
        entryAddedOrUpdated(entry, key, oldValue, now);
        evict(key);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 85 with Data

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

the class MapProxySupport method getPartitionsForKeys.

private Collection<Integer> getPartitionsForKeys(Collection<Data> keys) {
    int partitions = partitionService.getPartitionCount();
    // TODO: is there better way to estimate the size?
    int capacity = min(partitions, keys.size());
    Set<Integer> partitionIds = new HashSet<Integer>(capacity);
    Iterator<Data> iterator = keys.iterator();
    while (iterator.hasNext() && partitionIds.size() < partitions) {
        Data key = iterator.next();
        partitionIds.add(partitionService.getPartitionId(key));
    }
    return partitionIds;
}
Also used : Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

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