We are using Hazelcast 2.3.1, in our hazelcast.xml configuration file we use write behind for an 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 holds the map and is used to put objects into it.HazelcastObjectPersister
which extends MapStore is used to persist Objects when Hazelcast is callingstoreAll()
.
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 when Hazelcast runs through this map and fetches the objects which should be stored in the storeAll method of the persister class, the map is locked for seconds and so a put into this map lasts this time. Is there any solution for this problem?