Hazelcast 3.12 IMap.lock() on Map better than ILock.lock() which is deprecated?

313 views
Skip to first unread message

yukt...@gmail.com

unread,
Sep 1, 2019, 6:36:55 AM9/1/19
to Hazelcast

Is Hazelcast IMap.lock() on Map better than ILock.lock() which is deprecated in version 3.12? Can we continue with the usage of IMap.lock() or is it too projected to be deprecated? What are the specific advantages of using locks on Map? Are locks on the map written on the same partition as that of the key? If so, where(which area of Hazelcast Distributed memory) are the general locks not tied to maps written to?

Lock mylock = Hazelcast.getLock(mylockobject); 
mylock.lock(); **//Deprecated**

 try {
      //dosomething
 }finally{
  mylock.unlock();
 }      

IMap map = Hazelcast.getMap("customers"); map.lock("1"); //Not deprecated
 try {
//dosomething
 }finally{
 map.unlock("1"); 
}

j...@hazelcast.com

unread,
Sep 8, 2019, 11:47:07 PM9/8/19
to Hazelcast
Scope of the lock acquired using map.lock(key) is this map only and only for the key in this map. In order words, you can solve race conditions on a map pessimistically using the map.lock API(s). ILock (and now FencedLock)is use for a cluster wide lock for coordination that are not specific to a single key, or related to map entries.
Reply all
Reply to author
Forward
0 new messages