Hazelcast EntryProcessor executes on all nodes

26 views
Skip to first unread message

Michael Horák

unread,
Feb 8, 2023, 7:17:18 AM2/8/23
to Hazelcast
Hello,

I am using an embeded version of Hazelcast 5.2.1 and I noticed that EntryProcessor executes on all cluster members.

In my entry processor, I have a logic which fetch some data from database (based on the data definition in the distributed map) and send the result into a bus. The problem is that I receive twice the same notification since the both cluster members execute the task.

Why the entry proccessor executes on both cluster members?

Is there a way to force the execution to only the key owner or at least that the entry processor is executed only once?

My entry processor definition:

public class myEntryProcessor implements EntryProcessor<String, SerializableSession, Void>, Offloadable, IdentifiedDataSerializable

Thanks for any help

Michael Horák

unread,
Feb 8, 2023, 10:38:36 AM2/8/23
to Hazelcast
I found the original problem, it is that getBackupProcessor method of my entry processor returns the entry processor itself. If I override the getBackupProcessor method and return null, the behaviour is as expected but I guess that my backups won't be updated with the new value right? Do I have to implement my custom BackupProcessor to keep the backups updated or the Hazelcast will synchronize the entry and it backups automatically at some point?

Dne středa 8. února 2023 v 13:17:18 UTC+1 uživatel Michael Horák napsal:

Ozan Kılıç

unread,
Feb 8, 2023, 10:44:52 AM2/8/23
to haze...@googlegroups.com
You can implement a backup entry processor where you only pass the value and call entry.setValue in process method:

@Override
public EntryProcessor<String, String, String> getBackupProcessor() {

return new EntryProcessor<String, String, String>() {
private final String updatedValueFromPrimary = updatedValue;

@Override
public String process(Map.Entry<String, String> entry) {
entry.setValue(updatedValueFromPrimary);
return "ok";
}
};
}
--
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/b4df9ccc-4481-4e38-8325-5eb0d420f472n%40googlegroups.com.


--
Ozan Kilic 
Support Manager, EMEA
Hazelcast

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

Ozan Kılıç

unread,
Feb 8, 2023, 10:50:31 AM2/8/23
to haze...@googlegroups.com
Heavy operations in entry processors affect the cluster stability.
Implement Offloadable interface for your entry processors and specify another executor for running these EPs to avoid running DB operations on partition threads. 

Even though Offloadable EPs run on the specified executors, their backup EPs run on partition threads. You should implement a custom backup EP that only passes the calculated value to the backup entry, like described in my previous reply. 


--
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.
Reply all
Reply to author
Forward
0 new messages