hklf
hklf

Reputation: 41

hazelcast maploader listener

I have a single member that has a MapStore/Loader that reads/writes to a database and also a client that adds an EntryAddedListener listener.

If the member is bounced, I see entry added listeners being fired, as the MapLoader reloads the data from database.

However this suggests to the client that new entries have been added, whereas in fact, they are only being "added" because of the node bootstrapping up.

Basically I don't want these listeners to be fired as a result of the MapLoader bootstrapping the map - they should only be fired afterwards.

How do I stop these MapLoader events firing off EntryAdded listeners?

Upvotes: 1

Views: 722

Answers (2)

Alexey Zotov
Alexey Zotov

Reputation: 19

It is possible to distinguish ADD and LOAD events starting from Hazelcast v3.11. This feature has been introduced as a part of hazelcast-13181 issue.

Also you may want to check Java-docs for EntryAddedListener and EntryLoadedListener for more details.

Upvotes: 1

tom.bujok
tom.bujok

Reputation: 1642

There's no way to do it. Loading an Entry using a MapLoader is basically adding an Entry to the Map.

What you could do is to add these listeners after the map has been loaded. If your loadingMode is set to EAGER it's easy to determine when the loading has finished completely.

In order to wait till the loading has finished you can invoke map.size() operation. When it finishes the map is fully-populated.

Upvotes: 2

Related Questions