Search in sources :

Example 1 with SerializationServiceBuilder

use of com.hazelcast.internal.serialization.SerializationServiceBuilder 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 SerializationServiceBuilder

use of com.hazelcast.internal.serialization.SerializationServiceBuilder 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 3 with SerializationServiceBuilder

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

the class CacheSerializationTest method setup.

@Before
public void setup() {
    SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
    service = builder.build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) Before(org.junit.Before)

Example 4 with SerializationServiceBuilder

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

the class DefaultClientExtension method createSerializationService.

@Override
public InternalSerializationService createSerializationService(byte version) {
    try {
        ClientConfig config = client.getClientConfig();
        ClassLoader configClassLoader = config.getClassLoader();
        HazelcastInstance hazelcastInstance = client;
        PartitioningStrategy partitioningStrategy = getPartitioningStrategy(configClassLoader);
        SerializationConfig serializationConfig = config.getSerializationConfig() != null ? config.getSerializationConfig() : new SerializationConfig();
        SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
        if (version > 0) {
            builder.setVersion(version);
        }
        return builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(new HazelcastClientManagedContext(client, config.getManagedContext())).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).setNotActiveExceptionSupplier(HazelcastClientNotActiveException::new).setSchemaService(client.getSchemaService()).build();
    } catch (Exception e) {
        throw rethrow(e);
    }
}
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) HazelcastClientNotActiveException(com.hazelcast.client.HazelcastClientNotActiveException) DefaultPartitioningStrategy(com.hazelcast.partition.strategy.DefaultPartitioningStrategy) PartitioningStrategy(com.hazelcast.partition.PartitioningStrategy) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientNotActiveException(com.hazelcast.client.HazelcastClientNotActiveException)

Example 5 with SerializationServiceBuilder

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

the class DefaultNodeExtension method createSerializationService.

/**
 * Creates a serialization service. The {@code isCompatibility} parameter defines
 * whether the serialization format used by the service will conform to the
 * 3.x or the 4.x format.
 *
 * @param isCompatibility {@code true} if the serialized format should conform to the
 *                 3.x serialization format, {@code false} otherwise
 * @return the serialization service
 */
private InternalSerializationService createSerializationService(boolean isCompatibility) {
    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(ClusterProperty.SERIALIZATION_VERSION);
        ss = builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(hazelcastInstance.managedContext).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).setVersion(version).setSchemaService(node.memberSchemaService).setNotActiveExceptionSupplier(new Supplier<RuntimeException>() {

            @Override
            public RuntimeException get() {
                return new HazelcastInstanceNotActiveException();
            }
        }).isCompatibility(isCompatibility).build();
    } catch (Exception e) {
        throw rethrow(e);
    }
    return ss;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationConfig(com.hazelcast.config.SerializationConfig) PersistenceConfig(com.hazelcast.config.PersistenceConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigAccessor.getActiveMemberNetworkConfig(com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig) InstanceTrackingConfig(com.hazelcast.config.InstanceTrackingConfig) JetConfig(com.hazelcast.jet.config.JetConfig) SymmetricEncryptionConfig(com.hazelcast.config.SymmetricEncryptionConfig) Config(com.hazelcast.config.Config) SecurityConfig(com.hazelcast.config.SecurityConfig) AuditlogConfig(com.hazelcast.config.AuditlogConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) DefaultPartitioningStrategy(com.hazelcast.partition.strategy.DefaultPartitioningStrategy) PartitioningStrategy(com.hazelcast.partition.PartitioningStrategy) Supplier(java.util.function.Supplier) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) VersionMismatchException(com.hazelcast.internal.cluster.impl.VersionMismatchException) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)9 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)9 SerializationConfig (com.hazelcast.config.SerializationConfig)4 DefaultPartitioningStrategy (com.hazelcast.partition.strategy.DefaultPartitioningStrategy)4 Data (com.hazelcast.internal.serialization.Data)3 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 PartitioningStrategy (com.hazelcast.core.PartitioningStrategy)2 VersionMismatchException (com.hazelcast.internal.cluster.impl.VersionMismatchException)2 PartitioningStrategy (com.hazelcast.partition.PartitioningStrategy)2 Before (org.junit.Before)2 HazelcastClientNotActiveException (com.hazelcast.client.HazelcastClientNotActiveException)1 CollectionItem (com.hazelcast.collection.impl.collection.CollectionItem)1 AuditlogConfig (com.hazelcast.config.AuditlogConfig)1