Creating and using a distributed lock

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.

04e3a46efd2e243319b1bf9f7ef316f7?s=128

Katia Aresti

January 25, 2018
Tweet

Transcript

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

    Aresti
  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 https://github.com/karesti/vertx-api/tree/snowcamp/clustered https://github.com/karesti/vertx-api/tree/snowcamp-withlock
  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

    SnowCamp
  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: https://github.com/karesti/infinispan/tree/snowcamp

    tryLock/unlock: https://github.com/karesti/infinispan/tree/snowcamp-tryLock-Unlock tryLock with timeout: https://github.com/karesti/infinispan/tree/snowcamp-tryLockWithTimeout
  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 https://github.com/infinispan/infinispan/tree/master/lock Vert.x Cluster Manager https://github.com/vert-x3/vertx-infinispan

  18. @karesti @infinispan