Search in sources :

Example 1 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class DefaultNodeExtension method createSerializationService.

public InternalSerializationService createSerializationService() {
    InternalSerializationService ss;
    try {
        Config config = node.getConfig();
        ClassLoader configClassLoader = node.getConfigClassLoader();
        HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
        PartitioningStrategy partitioningStrategy = getPartitioningStrategy(configClassLoader);
        SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
        SerializationConfig serializationConfig = config.getSerializationConfig() != null ? config.getSerializationConfig() : new SerializationConfig();
        byte version = (byte) node.getProperties().getInteger(GroupProperty.SERIALIZATION_VERSION);
        ss = (InternalSerializationService) builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(hazelcastInstance.managedContext).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).setVersion(version).build();
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
    return ss;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationConfig(com.hazelcast.config.SerializationConfig) Config(com.hazelcast.config.Config) SerializationConfig(com.hazelcast.config.SerializationConfig) DefaultPartitioningStrategy(com.hazelcast.partition.strategy.DefaultPartitioningStrategy) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) VersionMismatchException(com.hazelcast.internal.cluster.impl.VersionMismatchException)

Example 2 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class TcpIpConnection_AbstractTest method setup.

@Before
public void setup() throws Exception {
    addressA = new Address("127.0.0.1", 5701);
    addressB = new Address("127.0.0.1", 5702);
    addressC = new Address("127.0.0.1", 5703);
    loggingService = new LoggingServiceImpl("somegroup", "log4j2", BuildInfoProvider.BUILD_INFO);
    logger = loggingService.getLogger(TcpIpConnection_AbstractTest.class);
    metricsRegistryA = newMetricsRegistry();
    connManagerA = newConnectionManager(addressA.getPort(), metricsRegistryA);
    ioServiceA = (MockIOService) connManagerA.getIoService();
    metricsRegistryB = newMetricsRegistry();
    connManagerB = newConnectionManager(addressB.getPort(), metricsRegistryB);
    ioServiceB = (MockIOService) connManagerB.getIoService();
    metricsRegistryC = newMetricsRegistry();
    connManagerC = newConnectionManager(addressC.getPort(), metricsRegistryC);
    ioServiceC = (MockIOService) connManagerB.getIoService();
    serializationService = (InternalSerializationService) new DefaultSerializationServiceBuilder().addDataSerializableFactory(TestDataFactory.FACTORY_ID, new TestDataFactory()).build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SocketAddress(java.net.SocketAddress) Address(com.hazelcast.nio.Address) LoggingServiceImpl(com.hazelcast.logging.LoggingServiceImpl) Before(org.junit.Before)

Example 3 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class LazyEntryViewFromRecordTest method createDefaultEntryView.

/**
     * Returns an entry-view instance populated with default values of fields.
     */
private EntryView createDefaultEntryView() {
    PartitioningStrategy mockPartitioningStrategy = mock(PartitioningStrategy.class);
    MapConfig mapConfig = new MapConfig();
    serializationService = new DefaultSerializationServiceBuilder().build();
    DataRecordFactory dataRecordFactory = new DataRecordFactory(mapConfig, serializationService, mockPartitioningStrategy);
    recordInstance = dataRecordFactory.newRecord(value);
    ((AbstractRecord) recordInstance).setKey(serializationService.toData(key));
    return new LazyEntryViewFromRecord(recordInstance, serializationService);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) AbstractRecord(com.hazelcast.map.impl.record.AbstractRecord) MapConfig(com.hazelcast.config.MapConfig) DataRecordFactory(com.hazelcast.map.impl.record.DataRecordFactory)

Example 4 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class DefaultClientExtension method createSerializationService.

@Override
public InternalSerializationService createSerializationService(byte version) {
    InternalSerializationService ss;
    try {
        ClientConfig config = client.getClientConfig();
        ClassLoader configClassLoader = config.getClassLoader();
        HazelcastInstance hazelcastInstance = client;
        PartitioningStrategy partitioningStrategy = getPartitioningStrategy(configClassLoader);
        SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
        SerializationConfig serializationConfig = config.getSerializationConfig() != null ? config.getSerializationConfig() : new SerializationConfig();
        if (version > 0) {
            builder.setVersion(version);
        }
        ss = builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(new HazelcastClientManagedContext(client, config.getManagedContext())).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).build();
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
    return ss;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SerializationConfig(com.hazelcast.config.SerializationConfig) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) DefaultPartitioningStrategy(com.hazelcast.partition.strategy.DefaultPartitioningStrategy) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 5 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class WanPublisherConfigTest method testSerialization.

@Test
public void testSerialization() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("key", "value");
    config.setGroupName("groupName");
    config.setQueueCapacity(500);
    config.setQueueFullBehavior(WANQueueFullBehavior.THROW_EXCEPTION);
    config.setProperties(properties);
    config.setClassName("className");
    config.setImplementation("implementation");
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Data serialized = serializationService.toData(config);
    WanPublisherConfig deserialized = serializationService.toObject(serialized);
    assertWanPublisherConfig(config, deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HashMap(java.util.HashMap) 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)

Aggregations

DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)197 Test (org.junit.Test)146 QuickTest (com.hazelcast.test.annotation.QuickTest)119 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)91 Data (com.hazelcast.internal.serialization.Data)56 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)56 SerializationService (com.hazelcast.internal.serialization.SerializationService)50 SerializationService (com.hazelcast.spi.serialization.SerializationService)40 SerializationConfig (com.hazelcast.config.SerializationConfig)36 Before (org.junit.Before)22 ClassDefinitionBuilder (com.hazelcast.nio.serialization.ClassDefinitionBuilder)20 HeapData (com.hazelcast.internal.serialization.impl.HeapData)18 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)16 CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)15 CustomSerializationTest (com.hazelcast.internal.serialization.impl.CustomSerializationTest)14 ParallelTest (com.hazelcast.test.annotation.ParallelTest)13 Parameters (junitparams.Parameters)13 ArrayList (java.util.ArrayList)12 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)10 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)9