Slide 1

Slide 1 text

Creating and using a distributed lock Snowcamp 2018 - Katia Aresti

Slide 2

Slide 2 text

@karesti

Slide 3

Slide 3 text

3

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

5 Clustering with Infinispan As cMa

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Clustered Lock Non reentrant Non blocking Auto-release on Failure, Split-brain Node level Owner (!thread)

Slide 8

Slide 8 text

Clustered Lock Manager - Infinispan 9.2

Slide 9

Slide 9 text

Clustered Lock - Infinispan 9.2

Slide 10

Slide 10 text

Node N Node 1 Node 2 Node 3 ... Lock SnowCamp

Slide 11

Slide 11 text

Node N Node 1 Node 2 Node 3 ... ClusteredLockManager Clustered Lock Lock SnowCamp Address ( not a thread) RPC calls to change lock state

Slide 12

Slide 12 text

Clustered Lock - Infinispan 9.2

Slide 13

Slide 13 text

Using Infinispan API

Slide 14

Slide 14 text

Comparing with the JDK

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Feedback please! Clustered Lock https://github.com/infinispan/infinispan/tree/master/lock Vert.x Cluster Manager https://github.com/vert-x3/vertx-infinispan

Slide 18

Slide 18 text

@karesti @infinispan