Search in sources :

Example 31 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class MemberMapRecordStateStressTest method assertFinalRecordStateIsReadPermitted.

private void assertFinalRecordStateIsReadPermitted(HazelcastInstance member, NearCache nearCache) {
    InternalSerializationService ss = getSerializationService(member);
    DefaultNearCache unwrap = (DefaultNearCache) nearCache.unwrap(DefaultNearCache.class);
    for (int i = 0; i < KEY_SPACE; i++) {
        Data key = ss.toData(i);
        AbstractNearCacheRecordStore nearCacheRecordStore = (AbstractNearCacheRecordStore) unwrap.getNearCacheRecordStore();
        NearCacheRecord record = nearCacheRecordStore.getRecord(key);
        if (record != null) {
            assertEquals(record.toString(), READ_PERMITTED, record.getRecordState());
        }
    }
}
Also used : DefaultNearCache(com.hazelcast.internal.nearcache.impl.DefaultNearCache) NearCacheRecord(com.hazelcast.internal.nearcache.NearCacheRecord) Data(com.hazelcast.nio.serialization.Data) AbstractNearCacheRecordStore(com.hazelcast.internal.nearcache.impl.store.AbstractNearCacheRecordStore) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 32 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class PortableClassVersionTest method testDifferentClassAndServiceVersionsUsingDataWriteAndRead.

@Test
public void testDifferentClassAndServiceVersionsUsingDataWriteAndRead() throws Exception {
    InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().setPortableVersion(1).addPortableFactory(FACTORY_ID, new PortableFactory() {

        public Portable create(int classId) {
            return new NamedPortable();
        }
    }).build();
    InternalSerializationService serializationService2 = new DefaultSerializationServiceBuilder().setPortableVersion(2).addPortableFactory(FACTORY_ID, new PortableFactory() {

        public Portable create(int classId) {
            return new NamedPortableV2();
        }
    }).build();
    testDifferentClassVersionsUsingDataWriteAndRead(serializationService, serializationService2);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 33 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class PortableTest method testRawData.

@Test
public void testRawData() {
    int portableVersion = 1;
    final InternalSerializationService serializationService = createSerializationService(1);
    RawDataPortable p = new RawDataPortable(System.currentTimeMillis(), "test chars".toCharArray(), new NamedPortable("named portable", 34567), 9876, "Testing raw portable", new ByteArrayDataSerializable("test bytes".getBytes()));
    ClassDefinitionBuilder builder = new ClassDefinitionBuilder(p.getFactoryId(), p.getClassId(), portableVersion);
    builder.addLongField("l").addCharArrayField("c").addPortableField("p", createNamedPortableClassDefinition(portableVersion));
    serializationService.getPortableContext().registerClassDefinition(builder.build());
    final Data data = serializationService.toData(p);
    assertEquals(p, serializationService.toObject(data));
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 34 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class PortableTest method testRawDataInvalidWrite.

@Test(expected = HazelcastSerializationException.class)
public void testRawDataInvalidWrite() {
    int portableVersion = 1;
    final InternalSerializationService serializationService = createSerializationService(1);
    RawDataPortable p = new InvalidRawDataPortable(System.currentTimeMillis(), "test chars".toCharArray(), new NamedPortable("named portable", 34567), 9876, "Testing raw portable", new ByteArrayDataSerializable("test bytes".getBytes()));
    ClassDefinitionBuilder builder = new ClassDefinitionBuilder(p.getFactoryId(), p.getClassId(), portableVersion);
    builder.addLongField("l").addCharArrayField("c").addPortableField("p", createNamedPortableClassDefinition(portableVersion));
    serializationService.getPortableContext().registerClassDefinition(builder.build());
    final Data data = serializationService.toData(p);
    assertEquals(p, serializationService.toObject(data));
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 35 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class PortableTest method testClassDefinitionLookupBigEndianHeapData.

@Test
public void testClassDefinitionLookupBigEndianHeapData() throws IOException {
    InternalSerializationService ss = new DefaultSerializationServiceBuilder().setByteOrder(ByteOrder.BIG_ENDIAN).build();
    testClassDefinitionLookup(ss);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)38 QuickTest (com.hazelcast.test.annotation.QuickTest)15 Test (org.junit.Test)15 Data (com.hazelcast.nio.serialization.Data)14 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)12 Map (java.util.Map)6 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)5 IMap (com.hazelcast.core.IMap)4 QueryCacheRecord (com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)4 SerializationService (com.hazelcast.spi.serialization.SerializationService)4 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 QueryEntry (com.hazelcast.query.impl.QueryEntry)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 SerializationConfig (com.hazelcast.config.SerializationConfig)2 PartitioningStrategy (com.hazelcast.core.PartitioningStrategy)2 TransactionalMap (com.hazelcast.core.TransactionalMap)2 NearCacheRecord (com.hazelcast.internal.nearcache.NearCacheRecord)2 DefaultNearCache (com.hazelcast.internal.nearcache.impl.DefaultNearCache)2 AbstractNearCacheRecordStore (com.hazelcast.internal.nearcache.impl.store.AbstractNearCacheRecordStore)2 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)2