Save 37% off PRO during our Black Friday Sale! »

Creating and using a distributed lock

04e3a46efd2e243319b1bf9f7ef316f7?s=47 Katia Aresti
January 25, 2018

Creating and using a distributed lock

How to use a distributed lock to coordinate Vert.x applications in clustered mode.
The Vert.x example uses Vert.x - Infinispan cluster manager, powered by Infinispan 9.2. Infinispan 9.2 has a new ClusteredLock API to solve concurrency problems between Infinispan nodes. This presentation looks under the hood and shows on live-coding style how this new API has been created with already existing and production ready functionalities in Infinispan.


Katia Aresti

January 25, 2018


  1. Creating and using a distributed lock Snowcamp 2018 - Katia

  2. @karesti

  3. 3

  4. 4 Distributed cache (in memory datagrid) key/value Uses peer-to-peer communication

    No master/slave No bottleneck or SPOF Search, Streams, integration with Spark, Kafka, Hadoop, Vert.x… Embedded and Client/Server
  5. 5 Clustering with Infinispan As cMa

  6. 6 Clustered Vert.x application example Ran Id P od Reb

    o s Mon in Eve B s 2. Con f o d s ID 4. Con f o d s RE 3. Sen d es RE 1. Sen d es ID
  7. Clustered Lock Non reentrant Non blocking Auto-release on Failure, Split-brain

    Node level Owner (!thread)
  8. Clustered Lock Manager - Infinispan 9.2

  9. Clustered Lock - Infinispan 9.2

  10. Node N Node 1 Node 2 Node 3 ... Lock

  11. Node N Node 1 Node 2 Node 3 ... ClusteredLockManager

    Clustered Lock Lock SnowCamp Address ( not a thread) RPC calls to change lock state
  12. Clustered Lock - Infinispan 9.2

  13. Using Infinispan API

  14. Comparing with the JDK

  15. Coding tryLock(), unlock() and tryLock(time, unit) ! Initial state:

    tryLock/unlock: tryLock with timeout:
  16. Final thoughts and roadmap The power of distributed caches don’t

    stop on caching! Concurrency is not simple (at all) Creating reentrant locks too Adding ownership levels for locking (dealing concurrency in each node too) Locks for client / server mode Other structures available : Multimap, Counters ... Coming : Topics, Sorted Sets
  17. Feedback please! Clustered Lock Vert.x Cluster Manager

  18. @karesti @infinispan