Hazelcast serializer/deserializer

3.3k Views Asked by At

How to configure serializer/deserializer at the cluster level. I am able to set the serializer/deserializer at client level using the following Java code.

ClientConfig clientConfig = new ClientConfig();
SerializerConfig userDataSerializer = new
SerializerConfig().setTypeClass(UserData.class).setImplementation(new
UserDataSerializer()); clientConfig.getSerializationConfig().addSerializerConfig(userDataSerializer);

But while make SQL query it's throwing following error.

Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: There is no suitable de-serializer for type 2. This exception is likely to be caused by differences in the serialization configuration between members or between clients and members.

Above error is happening because the Hazelcast cluster does not know how to serializer/deserializer the object.

I am using a custom serializer using Kryo to serialize (based on this blog http://blog.hazelcast.com/comparing-serialization-methods/)

Please help!

2

There are 2 best solutions below

0
On

In the cluster, each node needs to know the serializer/de-serializer to perform the Predicate/SQLPredicate. For that, the required serializer class (as a Java jar file) should be present in start command Java CLASSPATH.

2
On

If you're running a query, the server-side of the cluster will need to be able to de-serialize the object.

The serialization mechanism on the server-side has to match the client-side to work ; so helpfully here you can use the same on both.

As you need to do is extend the Config on the server-side in the same way as you extend the ClientConfig on the client-side.

This is roughly what you want.