When/where does MapStore.store()/storeAll() get called?

251 views
Skip to first unread message

Vivek Pandey

unread,
Apr 28, 2010, 5:41:03 PM4/28/10
to haze...@googlegroups.com
Lets assume, I have 3 hazelcast nodes and each node has persistence enabled. If only the first(only one) node is writing to the map, I was expecting that MapStore.store/storeAll event is sent to all 3 nodes. Infact I see kind of random behavior. store() gets called on node1 (which is calling IMap.put()) but after certain number of entries I see node2's mapStore.store() is getting called and then after sometime node1's store is called.

Is there any configuration that I can use to control which node's mapstore get called? I am trying to make sure that each node's MapStore.store/storeAll get called so that I can create a local (to each node) persistence store, kind of distributed persistence store. Is it possible?

-vivek.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

Luca Garulli

unread,
Apr 28, 2010, 6:13:43 PM4/28/10
to hazelcast
Hi,
the store() is called only against the owner node. The backup nodes mantains entries only in RAM until someone became the owner (in case of crash for example).

You have experienced the store() on different nodes because the keys was different and hazelcast has distributed among the nodes using its Distributed Hash Table algorithm.

bye,
Luca Garulli

Vivek Pandey

unread,
Apr 28, 2010, 6:39:01 PM4/28/10
to haze...@googlegroups.com
On Wed, Apr 28, 2010 at 3:13 PM, Luca Garulli <l.ga...@gmail.com> wrote:
Hi,
the store() is called only against the owner node. The backup nodes mantains entries only in RAM until someone became the owner (in case of crash for example).


Thats exactly what I am trying to achieve. If the primary node dies, I want to have new persistence saved to the next node (new owner). I this how its supposed to work? What I see is that the current behavior assumes there is centralized store, hence AbstractMapStore.init/destroy is per hazelcast instance!
 
You have experienced the store() on different nodes because the keys was different and hazelcast has distributed among the nodes using its Distributed Hash Table algorithm.

I See. 

thanks,

-vivek. 

bye,
Luca Garulli


On 28 April 2010 23:41, Vivek Pandey <vivek....@gmail.com> wrote:
Lets assume, I have 3 hazelcast nodes and each node has persistence enabled. If only the first(only one) node is writing to the map, I was expecting that MapStore.store/storeAll event is sent to all 3 nodes. Infact I see kind of random behavior. store() gets called on node1 (which is calling IMap.put()) but after certain number of entries I see node2's mapStore.store() is getting called and then after sometime node1's store is called.

Is there any configuration that I can use to control which node's mapstore get called? I am trying to make sure that each node's MapStore.store/storeAll get called so that I can create a local (to each node) persistence store, kind of distributed persistence store. Is it possible?

-vivek.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

Luca Garulli

unread,
Apr 28, 2010, 6:44:34 PM4/28/10
to hazelcast
I made some tests using Orient Key/Value Serve that uses Hazelcast to store entries. In effects when a node dies the backup node starts the migration and invoke the store for all the instances owned by the died node.

http://www.orientechnologies.com/orient-kv.htm

There is also a live demo: http://95.110.224.203:8020

bye,
Luca Garulli

Fuad Malikov

unread,
Apr 29, 2010, 2:38:24 AM4/29/10
to haze...@googlegroups.com
Hi Vivek, 

To understand how map entries are stored in Hazelcast please have a look at http://www.hazelcast.com/documentation.jsp#InternalsDistributedMap
Especially on the subject, What happens when a new member joins? it describes how hazelcast migrates the data. 
Please continue only after reading that chapter.
A member will call MapStore only if it owns some data, that is there is some partition on it. 
In your case all partitions were owned by the first member at the beginning. That's why only its map store was invoked. After some time, (10 sec- 1 min) some partitions were migrated to the second member also. So the second member also started to call map store. After waiting little bit more the third will also start calling map store. However they are not called at the same time. Each member decides on its own when to call the MapStore. 
So if you set write behind and the period as 10 second. 

Each member will call map store in 10 second intervals but not at the same time. 

Hope this helps.

-fuad
--
--------------------------------------------
Fuad Malikov
Managing Partner, Hazelcast
http://www.hazelcast.com
+90.538.378.9777
http://www.linkedin.com/in/malikov
twitter @fuadm
Reply all
Reply to author
Forward
0 new messages