Reputation: 4562
According to this, "Each map.get(k) will be a remote operation" But where is the remote? For example, I have a node that writes into the IMap with key - k. Another 50 nodes that does read from the IMap using map.get(k). What happens when 50 nodes call map.get(k). Does each call come to the node that does the write? If so, how many copies of IMap does this "remote" node will create in responds to these 50 calls? Is it multi-threaded? Is this IMap singleton? Or each thread will create a deep copy of such IMap?
Upvotes: 1
Views: 263
Reputation: 823
But where is the remote?
The answer is in the preceding sentence in the documentation link you supplied: "Imagine that you are reading the key k so many times and k is owned by another member in your cluster.". Each key is hashed and mapped to a partition, as explained in http://docs.hazelcast.org/docs/3.7/manual/html-single/index.html#sharding-in-hazelcast and the "Data Partitioning" section that follows. The cluster member that owns that partition is the owner (or primary replica) of the key. Each read & write on that key will be executed by the same thread on that particular member (that is unless your configuration allows read from backup).
What happens when 50 nodes call map.get(k). Does each call come to the node that does the write?
Yes, it's always the key owner the one that executes operations on that key.
If so, how many copies of IMap does this "remote" node will create in responds to these 50 calls?
The member only has one instance of the IMap, no copies.
Is it multi-threaded?
No, all map operations involving the same key k
will be executed on the same partition thread on the same member which is the primary replica of that key. You may read more about threading model of operations in http://docs.hazelcast.org/docs/3.7/manual/html-single/index.html#operation-threading
Upvotes: 5