Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creating and using a distributed lock

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
Tweet

More Decks by Katia Aresti

Other Decks in Programming

Transcript

  1. 3

  2. 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
  3. 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
  4. Node N Node 1 Node 2 Node 3 ... ClusteredLockManager

    Clustered Lock Lock SnowCamp Address ( not a thread) RPC calls to change lock state
  5. 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
  6. 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