Search code examples
hazelcasthazelcast-imap

Hazelcast forcefully call loadAll() method when any of the Hazelcast member goes down


I have implemented read-through using MapLoader with loadAll key functionality which loads specific list of keys and value from database to Hazelcast map during map initialization. My question is if some of the member goes down, I need repopulate those keys and values accordingly. This is because we are aggressively using Hazelcast predicates to search the relevant data (not by the key) but if one the member goes down there are chances we won't be getting actual result from cache.

As far as I know Hazelcast will also not create any backup of data which are configured with MapLoader. Only one option I can think of is to forcefully call loadAll function of MapLoader once any of the members goes down. But not really sure how to implement the same. I am also open for other suggestion.


Solution

  • As far as I know Hazelcast will also not create any backup of data which are configured with MapLoader.

    I am not sure what made you believe that. Backups and MapLoader are two separate configuration settings on a map and you can configure them independently. So unless you configured zero backups you will have a backup of your data, even when loaded by a MapLoader.

    For more see Making Your Map Data Safe section in the documentation.

    If you want to reload the data using MapLoader you can use com.hazelcast.map.IMap#loadAll(boolean) for all data or com.hazelcast.map.IMap#loadAll(java.util.Set<K>, boolean) for specific set of keys.