Difference between Lock and Map locks w.r.t. to partitioning

27 views
Skip to first unread message

shivi.g...@gmail.com

unread,
Aug 28, 2019, 2:02:34 AM8/28/19
to Hazelcast
As per hazelcast documentation, Map is partitioned HazelCast data structure and Lock is non-partitioned HazelCast data structure. Then we want some clarity:
1. then what kind of behavior will be there for Map.lock(), will be partitioned or non-partitioned.
2. Also, as we have backup configuration for Map, is it valid for Map.lock() as well?


Zeynel Demirci

unread,
Aug 28, 2019, 4:58:07 PM8/28/19
to Hazelcast
They are two different distributed data structures. Lock is the distributed implementation of `java.util.concurrent.locks.Lock` and Map is distributed form of `java.util.Map`.

When you use Lock, it will be executed by a single thread in the entire cluster. IMap.lock() put locks on specific entry so it is not behaving like ILock. 

Q1- I believe being and partitioned or non-partitioned are different concepts. IMap.lock prevents concurrent threads to operate on the locked entry in the same member at the same time. 
Q2- A backup owner does not have IMap.locks but if the primary owner fails then it will get promoted to the primary owner and the caller client which has acquired the lock will switch to the new primary owner.

Hope that helps.

yukt...@gmail.com

unread,
Sep 1, 2019, 6:36:55 AM9/1/19
to Hazelcast
@deza I believe the question is more w.r.t where the locks associated to a map are stored as against the general lock objects .Are both variants of locks internally mapped to partitions?

Ahmet Mircik

unread,
Sep 2, 2019, 3:30:13 AM9/2/19
to Hazelcast
Please see answers inlined.

On Wed, Aug 28, 2019 at 9:02 AM <shivi.g...@gmail.com> wrote:
As per hazelcast documentation, Map is partitioned HazelCast data structure and Lock is non-partitioned HazelCast data structure. Then we want some clarity:
1. then what kind of behavior will be there for Map.lock(), will be partitioned or non-partitioned.
It will be partitioned too.  

2. Also, as we have backup configuration for Map, is it valid for Map.lock() as well?
Yes same backup configuration is also valid for lock.


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/a82f276e-1789-4899-b436-6bf3bd093eba%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages