Using EntryProcessor with Portable domain models

63 views
Skip to first unread message

Rajesh Bachani

unread,
Jul 28, 2020, 7:05:11 PM7/28/20
to Hazelcast
Hello 
I have tried to search for similar problems, but have not got any answer that can explain or help me resolve my problem. 
Here is some description. 

I have a domain model which is Portable, and is supposed to be stored in an IMap in hazelcast. 
I have an entity processor, which processes the model from the map, and accordingly updates it based on the new data. 

Now, when I run in multi node hazelcast cluster, I get a serialization exception for the Entry processor, saying it cannot be serialized, and in the stack trace I see it's using the Java serialization, because truly, I have not set Portable or any other mechanism for the entity processor.
So what should I do? Should the EP be Portable as well, or somehow can I avoid it, because ideally, the EP should be on all other nodes too, because this is a separate class in the classpath. Or do I have to specify that the EP would be available on the destination node, so hazelcast doesn't try to serialize it? 

I don't understand why does it need serialization in first place, and secondly, if it does, this is a conflict, that EP and other models end up using different serialization which hazelcast cannot manage intelligently? 

HELP! 
Thanks
Rajesh. 

Gokhan Oner

unread,
Jul 29, 2020, 3:27:39 AM7/29/20
to Hazelcast
Rajesh

Issue is, when you have a Java Serializable class, Hazelcast passes it to Java to Serialize/Des. & it fails since Java doesn't know anything about Portable or any other Hazelcast specific serialization interfaces.

Instead of portable, you can make your EP DataSerializable, this should work. Can you give it a try?
Thanks
Gokhan

Rajesh Bachani

unread,
Jul 29, 2020, 4:19:33 AM7/29/20
to Hazelcast
Hi Gokhan
Thanks for the help. 
The thing with DataSerializable is that it doesn't support versioning, which is important in our case. So, VersionedPortable was what I wanted to use for the purpose. 
Is there any other solution that can be used? 
Is there a way to prevent entity processor from being serialized in the first place, if the class exists on all the nodes already? Does Hazelcast support any such mechanism? 
Regards
Rajesh. 

Rajesh Bachani

unread,
Jul 29, 2020, 4:28:51 AM7/29/20
to Hazelcast
Also wondering if there is anything that the enterprise version could help me with, because we could very well purchase that too. Am going to check a little on that. 

M. Sancar Koyunlu

unread,
Aug 10, 2020, 7:37:40 AM8/10/20
to Hazelcast
Hi Rajesh, 
There seems to be some confusion on this topic. Let me try to answer your questions. 

If you have the class on all nodes and your EntryProcessor is Serializable, then you should not get any exception saying that it can not be serialized/deserialized. 
Can you share the stack trace that you are seeing? 
Are you seeing the stack trace on the node that you are submitting the EntryProcessor or on the receiving side?

EP should not necessarily be Portable/Identified. It is sufficient for it to be Serializable. But it can not be a plain object. We have to serialize it one way or another.  

> Is there a way to prevent entity processor from being serialized in the first place,
There is not. There has to be an identifier that will be sent to the cluster so that the cluster will lookup the class from the classpath using that identifier. When EP is Serializable it is the class name, when EP is Identified or Portable it is the Factory Id, Class Id. 

You should either have the EP on the classpath of all the members. Or you should use the User Code Deployment feature so that Hazelcast can deploy the class when needed for you. 
See the document here

VersionedPortable makes sense for Domain Objects.  Are you sure that you need versioning for your EP? What is the use case? Do you want to add a field later to your EntryProcessor without changing its logic? 
If you want to change to add a new logic with EntryProcessor, it should be a new class with a new class name. You can not update a class on the fly on java. Note that this is not related to Domain Objects and fields. I am talking about logic inside the `process` method of your EP. 


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/55be1dc3-93fc-4986-b847-ae6772f631b7n%40googlegroups.com.


--
Sancar Koyunlu
Software Engineer
   hazelcast®
 
 
2 W 5th Ave, Ste 300 | San Mateo, CA 94402 | USA
+1 (650) 521-5453 | hazelcast.com



This message contains confidential information and is intended only for the individuals named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version. -Hazelcast
Reply all
Reply to author
Forward
0 new messages