Search in sources :

Example 6 with SerializationService

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

the class EntryViewTest method testEntryViewSerialization.

@Test
public void testEntryViewSerialization() throws Exception {
    ReplicatedMapEntryView entryView = createEntryView();
    SerializationServiceBuilder serializationServiceBuilder = new DefaultSerializationServiceBuilder();
    SerializationService serializationService = serializationServiceBuilder.build();
    Data data = serializationService.toData(entryView);
    ReplicatedMapEntryView deserialized = serializationService.toObject(data);
    verifyFields(deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) 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 7 with SerializationService

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

the class WriteBehindQueueTest method createDelayedEntryList.

private List<DelayedEntry> createDelayedEntryList(int numberOfEntriesToCreate) {
    final List<DelayedEntry> list = new ArrayList<DelayedEntry>(numberOfEntriesToCreate);
    SerializationService ss1 = new DefaultSerializationServiceBuilder().build();
    final long storeTime = Clock.currentTimeMillis();
    for (int i = 0; i < numberOfEntriesToCreate; i++) {
        final DelayedEntry<Data, Object> e = DelayedEntries.createWithoutValue(ss1.toData(i), storeTime, i);
        list.add(e);
    }
    return list;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)

Example 8 with SerializationService

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

the class ClientExecutorServiceProxy method submitToRandomInternal.

private <T> void submitToRandomInternal(Callable<T> task, ExecutionCallback<T> callback) {
    checkNotNull(task, "task should not be null");
    String uuid = getUUID();
    int partitionId = randomPartitionId();
    ClientMessage request = ExecutorServiceSubmitToPartitionCodec.encodeRequest(name, uuid, toData(task), partitionId);
    ClientInvocationFuture f = invokeOnPartitionOwner(request, partitionId);
    SerializationService serializationService = getContext().getSerializationService();
    ClientDelegatingFuture<T> delegatingFuture = new ClientDelegatingFuture<T>(f, serializationService, SUBMIT_TO_PARTITION_DECODER);
    delegatingFuture.andThen(callback);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) SerializationService(com.hazelcast.spi.serialization.SerializationService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 9 with SerializationService

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

the class ClientExecutorServiceProxy method retrieveResultFromMessage.

private Object retrieveResultFromMessage(ClientInvocationFuture f) {
    Object response;
    try {
        SerializationService serializationService = getClient().getSerializationService();
        Data data = ExecutorServiceSubmitToAddressCodec.decodeResponse(f.get()).response;
        response = serializationService.toObject(data);
    } catch (Exception e) {
        response = e;
    }
    return response;
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) TimeoutException(java.util.concurrent.TimeoutException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) HazelcastException(com.hazelcast.core.HazelcastException) ExecutionException(java.util.concurrent.ExecutionException)

Example 10 with SerializationService

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

the class ClientExecutorServiceProxy method submitToKeyOwnerInternal.

private <T> void submitToKeyOwnerInternal(Callable<T> task, Object key, ExecutionCallback<T> callback) {
    checkNotNull(task, "task should not be null");
    String uuid = getUUID();
    int partitionId = getPartitionId(key);
    ClientMessage request = ExecutorServiceSubmitToPartitionCodec.encodeRequest(name, uuid, toData(task), partitionId);
    ClientInvocationFuture f = invokeOnPartitionOwner(request, partitionId);
    SerializationService serializationService = getContext().getSerializationService();
    ClientDelegatingFuture<T> delegatingFuture = new ClientDelegatingFuture<T>(f, serializationService, SUBMIT_TO_PARTITION_DECODER);
    delegatingFuture.andThen(callback);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) SerializationService(com.hazelcast.spi.serialization.SerializationService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

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