Search in sources :

Example 86 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class NearCachePreloaderConfigTest method testSerialization.

@Test
public void testSerialization() {
    config.setEnabled(true);
    config.setDirectory("myParentDirectory");
    config.setStoreInitialDelaySeconds(23);
    config.setStoreIntervalSeconds(42);
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Data serialized = serializationService.toData(config);
    NearCachePreloaderConfig deserialized = serializationService.toObject(serialized);
    assertEquals(config.isEnabled(), deserialized.isEnabled());
    assertEquals(config.getDirectory(), deserialized.getDirectory());
    assertEquals(config.getStoreInitialDelaySeconds(), deserialized.getStoreInitialDelaySeconds());
    assertEquals(config.getStoreIntervalSeconds(), deserialized.getStoreIntervalSeconds());
    assertEquals(config.toString(), deserialized.toString());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 87 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class RingbufferStoreConfigTest method setStoreImplementation.

@Test
public void setStoreImplementation() {
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    RingbufferStore<Data> store = RingbufferStoreWrapper.create("name", config, OBJECT, serializationService, null);
    config.setStoreImplementation(store);
    assertEquals(store, config.getStoreImplementation());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 88 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class ClientMapProxy method submitToKeyInternal.

public void submitToKeyInternal(Data keyData, EntryProcessor entryProcessor, final ExecutionCallback callback) {
    ClientMessage request = MapSubmitToKeyCodec.encodeRequest(name, toData(entryProcessor), keyData, getThreadId());
    try {
        ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
        SerializationService serializationService = getContext().getSerializationService();
        ClientDelegatingFuture clientDelegatingFuture = new ClientDelegatingFuture(future, serializationService, SUBMIT_TO_KEY_RESPONSE_DECODER);
        clientDelegatingFuture.andThen(callback);
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) HazelcastException(com.hazelcast.core.HazelcastException) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 89 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class ClientMapReduceProxy method toObjectMap.

private Map toObjectMap(ClientMessage res) {
    SerializationService serializationService = getContext().getSerializationService();
    Collection<Map.Entry<Data, Data>> entries = MapReduceForCustomCodec.decodeResponse(res).response;
    HashMap hashMap = new HashMap();
    for (Map.Entry<Data, Data> entry : entries) {
        Object key = serializationService.toObject(entry.getKey());
        Object value = serializationService.toObject(entry.getValue());
        hashMap.put(key, value);
    }
    return hashMap;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 90 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class ClientListProxy method listIterator.

@Override
public ListIterator<E> listIterator(int index) {
    ClientMessage request = ListListIteratorCodec.encodeRequest(name, index);
    ClientMessage response = invokeOnPartition(request);
    ListListIteratorCodec.ResponseParameters resultParameters = ListListIteratorCodec.decodeResponse(response);
    List<Data> resultCollection = resultParameters.response;
    SerializationService serializationService = getContext().getSerializationService();
    return new UnmodifiableLazyList<E>(resultCollection, serializationService).listIterator();
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ListListIteratorCodec(com.hazelcast.client.impl.protocol.codec.ListListIteratorCodec)

Aggregations

SerializationService (com.hazelcast.spi.serialization.SerializationService)120 Test (org.junit.Test)59 QuickTest (com.hazelcast.test.annotation.QuickTest)56 Data (com.hazelcast.nio.serialization.Data)54 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)46 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)28 ParallelTest (com.hazelcast.test.annotation.ParallelTest)22 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)18 HeapData (com.hazelcast.internal.serialization.impl.HeapData)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)10 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)9 ClientDelegatingFuture (com.hazelcast.client.util.ClientDelegatingFuture)8 Node (com.hazelcast.instance.Node)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 ICacheService (com.hazelcast.cache.impl.ICacheService)5 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)5 Record (com.hazelcast.map.impl.record.Record)5 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)3