简体   繁体   中英

Distributed ReadWrite Lock in Hazelcast

Looking for Distributed Reentrant ReadWrite Lock solution within Hazelcast. Does anyone know if its implemented or in the works ?

Found older thread referencing this, but no solution there: https://groups.google.com/forum/#!searchin/hazelcast/readwrite/hazelcast/YBQtgHPMdP0/xwoTYdu_Z58J

Hazelcast does not implement ReadWrite locks, and for good reason. I did try implement my own readwrite lock as suggested but its far too complicated.

The result was a readwrite lock that required too many network calls (lose performance). And still did not cater for node failures (if using multiple node)

the problem stems from the fact that you need to use semaphores for read lock (since traditional locks can only be unlocked by the thread that locked them). The issue with this is that when a node fails all of its locks will be release but the semaphores will not be released and therefore a deadlock is created.

We had several people working on this. And the issue mentioned was only the tip of the iceberg. If anyone did find a solution, please do share, but I dont think this is a feasible problem to solve since possible solutions loose performance and and far to complex.

It isn't implemented; but if you really need it you can build it on top of the hazelcast lower level infrastructure that is exposed through the spi.

this seems like a decent solution to the problem: https://github.com/ThoughtWire/hazelcast-locks

It implements the java.util.concurrent.locks.ReadWriteLock interface in a distributed way using Hazelcast. It is a bit complicated to describe, but looking through the source is understandable. Deserves a review.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM