0
votes

I am running hazelcast members and clients with below context:

Hazelcast clients, members with persistence As depicted in above diagram:

  1. I want the clients to control the (de)serialization, and onboard new clients without hazelcast members being involved in serializtion business.
  2. Want to make Hazelcast Map persistent based on naming conventions, e.g. All maps with "*Store" matching pattern, needs to be persisted to cassandra db.
  3. Since i chose to persist in binary format, I would like same byte[] stored in hazelcast to be supplied to the mapstore interface.

My problem is - hazelcast seems to apply deserializer before calling the mapstore .store() method and looks for the serializer class with originally stored typeId on the server side. The logical solution is either hazelcast does not apply deserializer for mapstore if my mapstore type is byte[], or have let me define deserializer which would work regardless of typeId. Looks like both does not seem to be possible.

Any idea to tackle the problem is greatly appreciated.

2

2 Answers

0
votes

@kiran,

Some addition to @wildnez s answer:

  1. Normally, if you have a Pojo & using MapStore, members also need to know the Pojo. But in your case, since you're OK with byte[], you can store entry as byte[] from the client side, meaning your IMap must be IMap. Then members won't be dealing worth any deserialization. So you'll do the serialization manually & store the byte[] to Hazelcast IMap. As alternate, you can define different serializers/deserializers for members & clients and for those classes, you can always return byte[] on the member. I personally prefer the first solution.

  2. Define a wildcard IMap config for *Store maps & put a generic MapStore implementation. By implementing MapLoaderLifecycleSupport, you can get the map name in your MapStore as well if needed. Please see http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#storing-entries-to-multiple-maps

  3. If your Map is IMap then you'll get byte[] in your MapStore as well, as described in 1.

0
votes

In default case (in-memory-format set to BINARY) Serialisation and Deserialisation happens only on client side. However, you are using MapStore that requires Hazelcast to provide the actual entry object to the MapStore.store method, hence the deserialisation on server. Otherwise you would only be receiving a byte[] in MapStore.