Search in sources :

Example 21 with Data

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

the class QueueStoreWrapper method loadAll.

@Override
public Map<Long, Data> loadAll(Collection<Long> keys) {
    if (!enabled) {
        return null;
    }
    final Map<Long, ?> map = store.loadAll(keys);
    if (map == null) {
        return Collections.emptyMap();
    }
    final Map<Long, Data> dataMap = new HashMap<Long, Data>(map.size());
    if (binary) {
        for (Map.Entry<Long, ?> entry : map.entrySet()) {
            byte[] dataBuffer = (byte[]) entry.getValue();
            Data data = new HeapData(Arrays.copyOf(dataBuffer, dataBuffer.length));
            dataMap.put(entry.getKey(), data);
        }
    } else {
        for (Map.Entry<Long, ?> entry : map.entrySet()) {
            dataMap.put(entry.getKey(), serializationService.toData(entry.getValue()));
        }
    }
    return dataMap;
}
Also used : HashMap(java.util.HashMap) Data(com.hazelcast.nio.serialization.Data) HeapData(com.hazelcast.internal.serialization.impl.HeapData) HeapData(com.hazelcast.internal.serialization.impl.HeapData) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with Data

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

the class AddAllBackupOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeInt(dataMap.size());
    for (Map.Entry<Long, Data> entry : dataMap.entrySet()) {
        long itemId = entry.getKey();
        Data value = entry.getValue();
        out.writeLong(itemId);
        out.writeData(value);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map) HashMap(java.util.HashMap)

Example 23 with Data

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

the class AddAllOperation method afterRun.

@Override
public void afterRun() throws Exception {
    LocalQueueStatsImpl stats = getQueueService().getLocalQueueStatsImpl(name);
    stats.incrementOtherOperations();
    if (Boolean.TRUE.equals(response)) {
        for (Data data : dataList) {
            publishEvent(ItemEventType.ADDED, data);
        }
    }
}
Also used : LocalQueueStatsImpl(com.hazelcast.monitor.impl.LocalQueueStatsImpl) Data(com.hazelcast.nio.serialization.Data)

Example 24 with Data

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

the class ClearOperation method afterRun.

@Override
public void afterRun() throws Exception {
    LocalQueueStatsImpl stats = getQueueService().getLocalQueueStatsImpl(name);
    stats.incrementOtherOperations();
    for (Data data : dataMap.values()) {
        publishEvent(ItemEventType.REMOVED, data);
    }
}
Also used : LocalQueueStatsImpl(com.hazelcast.monitor.impl.LocalQueueStatsImpl) Data(com.hazelcast.nio.serialization.Data)

Example 25 with Data

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

the class CompareAndRemoveOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeBoolean(retain);
    out.writeInt(dataList.size());
    for (Data data : dataList) {
        out.writeData(data);
    }
}
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