Search in sources :

Example 31 with SerializationService

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

the class XAResourceProxy method clearRemoteTransactions.

private void clearRemoteTransactions(Xid xid) {
    SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
    SerializationService serializationService = getContext().getSerializationService();
    Data xidData = serializationService.toData(serializableXID);
    ClientMessage request = XATransactionClearRemoteCodec.encodeRequest(serializableXID);
    invoke(request, xidData);
}
Also used : SerializableXID(com.hazelcast.transaction.impl.xa.SerializableXID) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 32 with SerializationService

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

the class PartitionPredicateTest method testSerialization.

@Test
public void testSerialization() {
    SerializationService serializationService = getSerializationService(local);
    Data serialized = serializationService.toData(predicate);
    PartitionPredicate deserialized = serializationService.toObject(serialized);
    assertEquals(partitionKey, deserialized.getPartitionKey());
    assertEquals(TruePredicate.INSTANCE, deserialized.getTarget());
}
Also used : PartitionPredicate(com.hazelcast.query.PartitionPredicate) 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 33 with SerializationService

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

the class QueryCacheIMapEventHandlingTest method executeMergeOperation.

private void executeMergeOperation(HazelcastInstance member, String mapName, int key, int mergedValue) throws Exception {
    Node node = getNode(member);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    SerializationService serializationService = getSerializationService(member);
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(mergedValue);
    EntryView<Data, Data> entryView = createSimpleEntryView(keyData, valueData, Mockito.mock(Record.class));
    MergeOperation mergeOperation = new MergeOperation(mapName, keyData, entryView, new PassThroughMergePolicy());
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    Future<Object> future = operationService.invokeOnPartition(SERVICE_NAME, mergeOperation, partitionId);
    future.get();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) PassThroughMergePolicy(com.hazelcast.map.merge.PassThroughMergePolicy) Node(com.hazelcast.instance.Node) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 34 with SerializationService

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

the class BinaryCompatibilityFileGenerator method generateBinaryFile.

public static void generateBinaryFile(DataOutputStream outputStream, Object object, ByteOrder byteOrder) throws IOException {
    SerializationService serializationService = createSerializationService(byteOrder);
    Data data = serializationService.toData(object);
    outputStream.writeUTF(createObjectKey(object, byteOrder));
    if (data == null) {
        outputStream.writeInt(NULL_OBJECT);
        return;
    }
    byte[] bytes = data.toByteArray();
    outputStream.writeInt(bytes.length);
    outputStream.write(bytes);
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data)

Example 35 with SerializationService

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

the class BinaryCompatibilityTest method basicSerializeDeserialize.

@Test
public void basicSerializeDeserialize() throws IOException {
    SerializationService serializationService = createSerializationService();
    Data data = serializationService.toData(object);
    Object readObject = serializationService.toObject(data);
    assertTrue(equals(object, readObject));
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) HeapData(com.hazelcast.internal.serialization.impl.HeapData) Test(org.junit.Test)

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