SlideShare a Scribd company logo
1 of 16
Download to read offline
Hazelcast Distributed Lock
Jadson Santos
Problem
• Some times you need a critical region in your system
where 2 threads can not access this part of code
concurrently, or something wrong will happen
•
• The easiest way to do this, is used the Java synchronized
block:
20/03/17 Hazelcast distributed lock
Problem
• The problem with this approach is that it just work in the
same Java Virtual Machine.
•
• What can we do if we have several instances of our
application running?
•
20/03/17 Hazelcast distributed lock
DataBase Distributed Lock
• The first option is use database based lock
•
• With Hibernate we have something like this:
•
20/03/17 Hazelcast distributed lock
DataBase Distributed Lock
• If two threads call the findObjectLock method at same
time, the second one you will wait until the first transaction
is closed.
•
• But if we have several databases or we can not use the
lock of the database?
•
20/03/17 Hazelcast distributed lock
HazelCast Distributed Lock
• The Hazelcast IMDG operational in-memory computing
platform helps leading companies worldwide manage their
data and distribute processing using in-memory storage
and parallel execution for breakthrough application speed
and scale [1].
•
• Hazelcast implement a distributed version of some Java
data structures like Maps, Set, Lists, Queue and Lock
•
20/03/17 Hazelcast distributed lock
HazelCast Distributed Lock
• ILock is the distributed implementation of
java.util.concurrent.locks.Lock. Meaning if you lock using
an ILock, the critical section that it guards is guaranteed
to be executed by only one thread in the entire cluster [2].
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast
• Just add a simple Jar to the application classpath.
•
• With Gradle stay like this:
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• Programmatically you need initiated a Config object for
the HazelCast instance
•
•
•
•
•
• First of all, we choose the cluster initial port number and
the number of ports the cluster we use.
•
• If you have several threads at same time access the
cluster, it is necessary have several ports
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• After that, we need to chose if use Multicast or specific
IPs addresses in the cluster, we configure to use specific
IPs
•
•
•
•
•
•
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• Now we inform these specific IPs to the cluster
•
•
•
•
•
•
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• At last, we specify which network interfaces that
Hazelcast should use
•
•
•
•
•
•
•
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• We can now instantiate a new Hazelcast Instance with
this configuration, how iniciate a Hazelcast instance is
slow, takes around 3 seconds, we initialized just one
instance per JVM
20/03/17 Hazelcast distributed lock
Configuring HazelCast Cluster
• The complete code:
20/03/17 Hazelcast distributed lock
Using HazelCast Cluster
• You must call HazelCast lock in a try-finally block to
ensure that the lock will be release.
• The lock have an identifier, so we can have different locks
in the same cluster
20/03/17 Hazelcast distributed lock
References
• [1] Hazelcast IMDG. The Leading Open Source In-
Memory Data Grid. https://hazelcast.org/
•
• [2] Lock
http://docs.hazelcast.org/docs/3.5/manual/html/lock.html
20/03/17 Hazelcast distributed lock

More Related Content

What's hot

Apache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the CoversApache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the CoversScyllaDB
 
Apache Tez – Present and Future
Apache Tez – Present and FutureApache Tez – Present and Future
Apache Tez – Present and FutureDataWorks Summit
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekVenkata Naga Ravi
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkDatabricks
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeDatabricks
 
Deep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDeep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDatabricks
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013mumrah
 
YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions Yugabyte
 
Reading The Source Code of Presto
Reading The Source Code of PrestoReading The Source Code of Presto
Reading The Source Code of PrestoTaro L. Saito
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsCloudera, Inc.
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudNoritaka Sekiyama
 
Memory Management in Apache Spark
Memory Management in Apache SparkMemory Management in Apache Spark
Memory Management in Apache SparkDatabricks
 
Optimizing Apache Spark SQL Joins
Optimizing Apache Spark SQL JoinsOptimizing Apache Spark SQL Joins
Optimizing Apache Spark SQL JoinsDatabricks
 
HDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon KimHDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon KimDatabricks
 
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache HadoopTez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache HadoopDataWorks Summit
 
Oracle Active Data Guard and Global Data Services in Action!
Oracle Active Data Guard and Global Data Services in Action!Oracle Active Data Guard and Global Data Services in Action!
Oracle Active Data Guard and Global Data Services in Action!Ludovico Caldara
 
Cosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceCosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceDatabricks
 
Transactional SQL in Apache Hive
Transactional SQL in Apache HiveTransactional SQL in Apache Hive
Transactional SQL in Apache HiveDataWorks Summit
 
Building an open data platform with apache iceberg
Building an open data platform with apache icebergBuilding an open data platform with apache iceberg
Building an open data platform with apache icebergAlluxio, Inc.
 
Streaming Visualization
Streaming VisualizationStreaming Visualization
Streaming VisualizationGuido Schmutz
 

What's hot (20)

Apache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the CoversApache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the Covers
 
Apache Tez – Present and Future
Apache Tez – Present and FutureApache Tez – Present and Future
Apache Tez – Present and Future
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeek
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache Spark
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
 
Deep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDeep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache Spark
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions
 
Reading The Source Code of Presto
Reading The Source Code of PrestoReading The Source Code of Presto
Reading The Source Code of Presto
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
 
Memory Management in Apache Spark
Memory Management in Apache SparkMemory Management in Apache Spark
Memory Management in Apache Spark
 
Optimizing Apache Spark SQL Joins
Optimizing Apache Spark SQL JoinsOptimizing Apache Spark SQL Joins
Optimizing Apache Spark SQL Joins
 
HDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon KimHDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon Kim
 
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache HadoopTez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
 
Oracle Active Data Guard and Global Data Services in Action!
Oracle Active Data Guard and Global Data Services in Action!Oracle Active Data Guard and Global Data Services in Action!
Oracle Active Data Guard and Global Data Services in Action!
 
Cosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceCosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle Service
 
Transactional SQL in Apache Hive
Transactional SQL in Apache HiveTransactional SQL in Apache Hive
Transactional SQL in Apache Hive
 
Building an open data platform with apache iceberg
Building an open data platform with apache icebergBuilding an open data platform with apache iceberg
Building an open data platform with apache iceberg
 
Streaming Visualization
Streaming VisualizationStreaming Visualization
Streaming Visualization
 

Similar to Hazelcast Distributed Lock Guide

Training Webinar: Enterprise application performance with distributed caching
Training Webinar: Enterprise application performance with distributed cachingTraining Webinar: Enterprise application performance with distributed caching
Training Webinar: Enterprise application performance with distributed cachingOutSystems
 
AEM - Binary less replication
AEM - Binary less replicationAEM - Binary less replication
AEM - Binary less replicationAshokkumar T A
 
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...DataStax
 
CloudStack - LinuxFest NorthWest
CloudStack - LinuxFest NorthWestCloudStack - LinuxFest NorthWest
CloudStack - LinuxFest NorthWestke4qqq
 
Where Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsWhere Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsConcentric Sky
 
Data has a better idea the in-memory data grid
Data has a better idea   the in-memory data gridData has a better idea   the in-memory data grid
Data has a better idea the in-memory data gridBogdan Dina
 
Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Comsysto Reply GmbH
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The WildSergio Bossa
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK toolsHaribabu Nandyal Padmanaban
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching SolutionsITviec
 
The State of Rootless Containers
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless ContainersAkihiro Suda
 
Elastic Migration 2.x to 6.x By Pankaj Gajjar
Elastic Migration 2.x to 6.x By Pankaj GajjarElastic Migration 2.x to 6.x By Pankaj Gajjar
Elastic Migration 2.x to 6.x By Pankaj GajjarPankaj Gajjar
 
Accelerate with ibm storage ibm spectrum virtualize hyper swap deep dive
Accelerate with ibm storage  ibm spectrum virtualize hyper swap deep diveAccelerate with ibm storage  ibm spectrum virtualize hyper swap deep dive
Accelerate with ibm storage ibm spectrum virtualize hyper swap deep divexKinAnx
 

Similar to Hazelcast Distributed Lock Guide (20)

Hazelcast sunum
Hazelcast sunumHazelcast sunum
Hazelcast sunum
 
Training Webinar: Enterprise application performance with distributed caching
Training Webinar: Enterprise application performance with distributed cachingTraining Webinar: Enterprise application performance with distributed caching
Training Webinar: Enterprise application performance with distributed caching
 
Hazelcast 101
Hazelcast 101Hazelcast 101
Hazelcast 101
 
Support distributed computing and caching avec hazelcast
Support distributed computing and caching avec hazelcastSupport distributed computing and caching avec hazelcast
Support distributed computing and caching avec hazelcast
 
AEM - Binary less replication
AEM - Binary less replicationAEM - Binary less replication
AEM - Binary less replication
 
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
 
CloudStack - LinuxFest NorthWest
CloudStack - LinuxFest NorthWestCloudStack - LinuxFest NorthWest
CloudStack - LinuxFest NorthWest
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Where Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsWhere Django Caching Bust at the Seams
Where Django Caching Bust at the Seams
 
Preparing for Multi-Cloud
Preparing for Multi-CloudPreparing for Multi-Cloud
Preparing for Multi-Cloud
 
Data has a better idea the in-memory data grid
Data has a better idea   the in-memory data gridData has a better idea   the in-memory data grid
Data has a better idea the in-memory data grid
 
Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The Wild
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
 
Mysql wp memcached
Mysql wp memcachedMysql wp memcached
Mysql wp memcached
 
The State of Rootless Containers
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless Containers
 
Elastic Migration 2.x to 6.x By Pankaj Gajjar
Elastic Migration 2.x to 6.x By Pankaj GajjarElastic Migration 2.x to 6.x By Pankaj Gajjar
Elastic Migration 2.x to 6.x By Pankaj Gajjar
 
Accelerate with ibm storage ibm spectrum virtualize hyper swap deep dive
Accelerate with ibm storage  ibm spectrum virtualize hyper swap deep diveAccelerate with ibm storage  ibm spectrum virtualize hyper swap deep dive
Accelerate with ibm storage ibm spectrum virtualize hyper swap deep dive
 

More from Jadson Santos

A Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesA Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesJadson Santos
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaJadson Santos
 
Continuous Delivery with Jenkins
Continuous Delivery with JenkinsContinuous Delivery with Jenkins
Continuous Delivery with JenkinsJadson Santos
 
Cd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuCd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuJadson Santos
 
Jenkins Continuous Delivery
Jenkins Continuous DeliveryJenkins Continuous Delivery
Jenkins Continuous DeliveryJadson Santos
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Introdução ao Flyway
Introdução ao FlywayIntrodução ao Flyway
Introdução ao FlywayJadson Santos
 
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...Jadson Santos
 
Usando hiberante de forma otimizada
Usando hiberante de forma otimizadaUsando hiberante de forma otimizada
Usando hiberante de forma otimizadaJadson Santos
 
Usando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFUsando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFJadson Santos
 
ICEIS 2013 Presentation
ICEIS 2013 PresentationICEIS 2013 Presentation
ICEIS 2013 PresentationJadson Santos
 
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Jadson Santos
 

More from Jadson Santos (19)

A Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesA Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring Practices
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
 
Continuous Delivery with Jenkins
Continuous Delivery with JenkinsContinuous Delivery with Jenkins
Continuous Delivery with Jenkins
 
Cd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuCd with Github Travis CI and Heroku
Cd with Github Travis CI and Heroku
 
Vue.js
Vue.jsVue.js
Vue.js
 
Jenkins Continuous Delivery
Jenkins Continuous DeliveryJenkins Continuous Delivery
Jenkins Continuous Delivery
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Testes Unitários
Testes UnitáriosTestes Unitários
Testes Unitários
 
Java8
Java8Java8
Java8
 
Gradle
GradleGradle
Gradle
 
Git
GitGit
Git
 
Introdução ao Flyway
Introdução ao FlywayIntrodução ao Flyway
Introdução ao Flyway
 
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
 
Usando hiberante de forma otimizada
Usando hiberante de forma otimizadaUsando hiberante de forma otimizada
Usando hiberante de forma otimizada
 
Usando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFUsando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSF
 
ICEIS 2013 Presentation
ICEIS 2013 PresentationICEIS 2013 Presentation
ICEIS 2013 Presentation
 
Enums
EnumsEnums
Enums
 
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
 

Recently uploaded

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Hazelcast Distributed Lock Guide

  • 2. Problem • Some times you need a critical region in your system where 2 threads can not access this part of code concurrently, or something wrong will happen • • The easiest way to do this, is used the Java synchronized block: 20/03/17 Hazelcast distributed lock
  • 3. Problem • The problem with this approach is that it just work in the same Java Virtual Machine. • • What can we do if we have several instances of our application running? • 20/03/17 Hazelcast distributed lock
  • 4. DataBase Distributed Lock • The first option is use database based lock • • With Hibernate we have something like this: • 20/03/17 Hazelcast distributed lock
  • 5. DataBase Distributed Lock • If two threads call the findObjectLock method at same time, the second one you will wait until the first transaction is closed. • • But if we have several databases or we can not use the lock of the database? • 20/03/17 Hazelcast distributed lock
  • 6. HazelCast Distributed Lock • The Hazelcast IMDG operational in-memory computing platform helps leading companies worldwide manage their data and distribute processing using in-memory storage and parallel execution for breakthrough application speed and scale [1]. • • Hazelcast implement a distributed version of some Java data structures like Maps, Set, Lists, Queue and Lock • 20/03/17 Hazelcast distributed lock
  • 7. HazelCast Distributed Lock • ILock is the distributed implementation of java.util.concurrent.locks.Lock. Meaning if you lock using an ILock, the critical section that it guards is guaranteed to be executed by only one thread in the entire cluster [2]. • 20/03/17 Hazelcast distributed lock
  • 8. Configuring HazelCast • Just add a simple Jar to the application classpath. • • With Gradle stay like this: • 20/03/17 Hazelcast distributed lock
  • 9. Configuring HazelCast Cluster • Programmatically you need initiated a Config object for the HazelCast instance • • • • • • First of all, we choose the cluster initial port number and the number of ports the cluster we use. • • If you have several threads at same time access the cluster, it is necessary have several ports • 20/03/17 Hazelcast distributed lock
  • 10. Configuring HazelCast Cluster • After that, we need to chose if use Multicast or specific IPs addresses in the cluster, we configure to use specific IPs • • • • • • • 20/03/17 Hazelcast distributed lock
  • 11. Configuring HazelCast Cluster • Now we inform these specific IPs to the cluster • • • • • • • 20/03/17 Hazelcast distributed lock
  • 12. Configuring HazelCast Cluster • At last, we specify which network interfaces that Hazelcast should use • • • • • • • 20/03/17 Hazelcast distributed lock
  • 13. Configuring HazelCast Cluster • We can now instantiate a new Hazelcast Instance with this configuration, how iniciate a Hazelcast instance is slow, takes around 3 seconds, we initialized just one instance per JVM 20/03/17 Hazelcast distributed lock
  • 14. Configuring HazelCast Cluster • The complete code: 20/03/17 Hazelcast distributed lock
  • 15. Using HazelCast Cluster • You must call HazelCast lock in a try-finally block to ensure that the lock will be release. • The lock have an identifier, so we can have different locks in the same cluster 20/03/17 Hazelcast distributed lock
  • 16. References • [1] Hazelcast IMDG. The Leading Open Source In- Memory Data Grid. https://hazelcast.org/ • • [2] Lock http://docs.hazelcast.org/docs/3.5/manual/html/lock.html 20/03/17 Hazelcast distributed lock