Hazelcast is blocked

We use Hazelcast 2.3.1, in our hazelcast.xml configuration file we use the entry for Hazelcast IMap:

<map name="HazelcastObjectOperations.objectMap"> <backup-count>1</backup-count> <map-store enabled="true"> <class-name>persister.HazelcastObjectPersister</class-name> <write-delay-seconds>10</write-delay-seconds> </map-store> </map> <properties> <property name="hazelcast.map.cleanup.delay.seconds">5</property> </properties> 

We got two classes

  • HazelcastObjectOperation , which contains the display and is used to place objects in it.
  • HazelcastObjectPersister , which extends MapStore, is used to save objects when Hazelcast calls storeAll() .
  public class HazelcastObjectOperation { protected final IMap<Long, MyHzcObj> objectMap; private final HazelcastInstance instance; public HazelcastObjectOperation() { this.instance = Hazelcast.getDefaultInstance(); this.objectMap = this.instance.getMap( "HazelcastObjectOperations.objectMap" ); } public void save( final MyHzcObj object ) { long start = System.currentTimeMillis(); IdGenerator generator = Hazelcast.getIdGenerator("generator"); this.objectMap.put( generator.newId(), object ); long end = System.currentTimeMillis(); } } 

The problem is that Hazelcast goes through this card and selects the objects that should be stored in the storeAll method of the persister class, the card is locked for a few seconds, and therefore is placed on this card. this time. Is there a solution to this problem?

+6
source share
1 answer

This was a Hazelcast issue and fixed: https://github.com/hazelcast/hazelcast/issues/293

BTW: Note that it is always better to use set() instead of put() if you don't need the old value. The problem is that put() trying to load the old value if mapstore is defined. set() does not attempt to load the old value, so it is faster and cleaner.

+3
source

Source: https://habr.com/ru/post/926282/


All Articles