use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class KeySetOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
List keys = new ArrayList();
for (ReplicatedRecordStore store : stores) {
keys.addAll(store.keySet(false));
}
ArrayList<Data> dataKeys = new ArrayList<Data>(keys.size());
SerializationService serializationService = getNodeEngine().getSerializationService();
for (Object key : keys) {
dataKeys.add(serializationService.toData(key));
}
response = new ReplicatedMapKeys(dataKeys);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class RequestMapDataOperation method getRecordSet.
private Set<RecordMigrationInfo> getRecordSet(ReplicatedRecordStore store) {
Set<RecordMigrationInfo> recordSet = new HashSet<RecordMigrationInfo>(store.size());
Iterator<ReplicatedRecord> iterator = store.recordIterator();
while (iterator.hasNext()) {
ReplicatedRecord record = iterator.next();
SerializationService serializationService = getNodeEngine().getSerializationService();
Data dataKey = serializationService.toData(record.getKeyInternal());
Data dataValue = serializationService.toData(record.getValueInternal());
recordSet.add(new RecordMigrationInfo(dataKey, dataValue, record.getTtlMillis()));
}
return recordSet;
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class ValuesOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
Collection<ReplicatedRecord> values = new ArrayList<ReplicatedRecord>();
for (ReplicatedRecordStore store : stores) {
values.addAll(store.values(false));
}
Collection<Data> dataValues = new ArrayList<Data>(values.size());
SerializationService serializationService = getNodeEngine().getSerializationService();
for (ReplicatedRecord value : values) {
dataValues.add(serializationService.toData(value.getValue()));
}
response = new ReplicatedMapValueCollection(dataValues);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class EntrySetOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
List<Map.Entry<Object, ReplicatedRecord>> entries = new ArrayList<Map.Entry<Object, ReplicatedRecord>>();
for (ReplicatedRecordStore store : stores) {
entries.addAll(store.entrySet(false));
}
ArrayList<Map.Entry<Data, Data>> dataEntries = new ArrayList<Map.Entry<Data, Data>>(entries.size());
SerializationService serializationService = getNodeEngine().getSerializationService();
for (Map.Entry<Object, ReplicatedRecord> entry : entries) {
Data key = serializationService.toData(entry.getKey());
Data value = serializationService.toData(entry.getValue().getValue());
dataEntries.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(key, value));
}
response = new ReplicatedMapEntries(dataEntries);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class NearCacheConfigTest method testSerialization.
@Test
public void testSerialization() {
config.setInvalidateOnChange(true);
config.setCacheLocalEntries(true);
config.setName("foobar");
config.setInMemoryFormat(InMemoryFormat.NATIVE);
config.setTimeToLiveSeconds(23);
config.setMaxIdleSeconds(42);
config.setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy.CACHE_ON_UPDATE);
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Data serialized = serializationService.toData(config);
NearCacheConfig deserialized = serializationService.toObject(serialized);
assertEquals(config.isInvalidateOnChange(), deserialized.isInvalidateOnChange());
assertEquals(config.isCacheLocalEntries(), deserialized.isCacheLocalEntries());
assertEquals(config.getName(), deserialized.getName());
assertEquals(config.getInMemoryFormat(), deserialized.getInMemoryFormat());
assertEquals(config.getTimeToLiveSeconds(), deserialized.getTimeToLiveSeconds());
assertEquals(config.getMaxIdleSeconds(), deserialized.getMaxIdleSeconds());
assertEquals(config.getLocalUpdatePolicy(), deserialized.getLocalUpdatePolicy());
assertEquals(config.getEvictionPolicy(), deserialized.getEvictionPolicy());
assertEquals(config.getMaxSize(), deserialized.getMaxSize());
assertEquals(config.toString(), deserialized.toString());
}
Aggregations