SlideShare a Scribd company logo
Speedment and Hazelcast
For Automatic Scale out of Existing SQL
Databases with Hazelcast
Per-Åke Minborg
www.speedment.com
The Shared Database Challenge
Database
Hazelcast
Hazelcast Application
Hazelcast Application
Hazelcast Application
The Shared Database Challenge
Database
Hazelcast
Hazelcast Application3:rd Party Application
3:rd Party Application
3:rd Party Application
Hazelcast Application
Hazelcast Application
The Shared Database Challenge
Database
Speedment
Hazelcast
Hazelcast Application3:rd Party Application
3:rd Party Application
3:rd Party Application
Hazelcast Application
Hazelcast Application
Overview
Database Speedment
Hazelcast
Node
Hazelcast
Node
Hazelcast
Node
Hazelcast
Node
INSERT
UPDATE
DELETE
Reflects all Data with Hazelcast
Exising SQL data from start
System.out.println(hazelcastMap.size());
-> 300024
Inserts
sql> insert into employees (emp_no, birth_date, first_name, last_name, gender, hire_date)
values (10001, '1953-09-02', 'Georgi', 'Facello', 'M', '1986-06-26');
Employees emp = hazelcastMap.get("10001"); System.out.println(emp);
-> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi", "last_name":
"Facello", "gender": "M", "hire_date": "1986-06-26"}
Updates
sql> update employees set first_name="Georgi2" where emp_no=10001;
Employees emp = hazelcastMap.get("10001"); System.out.println(emp);
-> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi2", "last_name":
"Facello", "gender": "M", "hire_date": "1986-06-26"}
Deletes
sql> delete from employees where emp_no = 10001;
Employees emp = hazelcastMap.get("10001"); System.out.println(emp);
-> null
Works with Transactions
SQL> START TRANSACTION;
update employees set first_name="Duangkaew"
where emp_no=10010;
update salaries set salary=salary+10 where
id=12322;
COMMIT;
// Backing hazelcast maps are updated atomically
Employees emp = employeesMap.get("10001");
Salaries sal = salaryMap.get("12322");
How to Install
•  Download software
•  Unzip distribution file
•  Start scripts in ”bin” directory
Generated Code
§  Database triggers
§  Triggerlog
§  Java POJOs for each selected table
§  Table manager/DAO
§  Hazelcast serialization factories
§  Hazelcast config support
§  Relational database metadata
§  Transaction support wrappers
Database Table
mysql> describe employees;
+------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+----------------+
| emp_no | int(11) | NO | PRI | NULL | auto_increment |
| birth_date | date | NO | | NULL | |
| first_name | varchar(14) | NO | | NULL | |
| last_name | varchar(16) | NO | | NULL | |
| gender | enum('M','F') | NO | | NULL | |
| hire_date | date | NO | | NULL | |
+------------+---------------+------+-----+---------+----------------+
POJO Representing a Row
public class Employees extends Struct<Employees>
implements IdentifiedDataSerializable {
private Integer empNo;
private Date birthDate;
private String firstName;
private String lastName;
private String gender;
private Date hireDate;
// Accessors, serialization, deserialization, etc.
@Override
public int getFactoryId() {
return EmployeesDataSerializableFactory.FACTORY_ID;
}
@Override
public void writeData(ObjectDataOutput out) throws
IOException {
int sizeOf = (int) sizeOf();
final ByteBuffer bb = ByteBuffer.allocate(sizeOf + 4);
bb.putInt(sizeOf);
writeObject(bb);
out.write(bb.array());
}
POJO Representing a Row
POJO Representing a Row
@Override
public void readData(ObjectDataInput in) throws IOException
{
int sizeOf = in.readInt();
final ByteBuffer bb = ByteBuffer.allocate(sizeOf);
in.readFully(bb.array());
try {
readObject(bb);
} catch (final ClassNotFoundException cnfe) {
_logger.error(cnfe.getMessage(), cnfe);
}
}
}
Manager/DAO Representing a Table
public class EmployeesMgr extends
Manager<Employees> {
@Override
public Employees getNewObjectInstance() {
return new Employees();
}
// insert, update, delete, finders, size,
etc.
Manager/DAO Representing a Table
@Override
public void add(final Employees employees) {
addHazelcast(employees);
}
@Override
public void remove(final Employees employees) {
removeHazelcast(employees);
}
}
Manager/DAO Representing a Table
protected void addHazelcast(final Employees employees) {
final String _key = employees._getPrimaryKeyString();
final TransactionalMap<String, Employees>
transactionMap = getHazelcastTransactionalMap();
if (transactionMap != null) {
transactionMap.put(_key, employees);
} else {
hcPrimaryKeyMap.put(_key, employees);
}
}
DataSerializableFactory per Table
public class EmployeesDataSerializableFactoryBase
implements DataSerializableFactory {
public static final int FACTORY_ID = 1221169916;
public static final int EMPLOYEES_ID = 0;
@Override
public IdentifiedDataSerializable create(int typeId)
{
return
EmployeesMgr.getInstance().getNewObjectInstance();
}
}
Configuration Support Class (One)
public class SpeedmentHazelcastConfig{
public static void addTo(final Config config) {
addTo(config.getSerializationConfig());
}
public static void addTo(final ClientConfig config) {
addTo(config.getSerializationConfig());
}
public static void addTo(final SerializationConfig
serializationConfig) {
serializationConfig.addDataSerializableFactory(
DepartmentsDataSerializableFactory.FACTORY_ID,
new DepartmentsDataSerializableFactory());
serializationConfig.addDataSerializableFactory(
DeptManagerDataSerializableFactory.FACTORY_ID,
new DeptManagerDataSerializableFactory());
serializationConfig.addDataSerializableFactory(
EmployeesDataSerializableFactory.FACTORY_ID,
new EmployeesDataSerializableFactory());
}
}
Transaction Support Classes
public class HazelcastTransactionHandlerFactory implements
TransactionHandlerFactory {
private final HazelcastInstance hazelcastInstance;
private final TransactionOptions transactionOptions;
public HazelcastTransactionHandlerFactory(HazelcastInstance
hazelcastInstance, TransactionOptions transactionOptions) {
this.hazelcastInstance = hazelcastInstance;
this.transactionOptions = transactionOptions;
}
@Override
public TransactionHandler newTransactionHandler() {
final TransactionContext context =
hazelcastInstance.newTransactionContext(transactionOptions);;
return new HazelcastTransactionHandler(context);
}
}
Transaction Support Classes
public class HazelcastTransactionHandler implements TransactionHandler
{
private final TransactionContext context;
public HazelcastTransactionHandler(TransactionContext context) {
this.context = context;
}
. . .
}
Transaction Support Classes
@Override
public void begin() {
context.beginTransaction();
}
@Override
public void commit() {
context.commitTransaction();
}
@Override
public void rollback() {
context.rollbackTransaction();
}
public TransactionContext getContext() {
return context;
}
How do you use it?
“Easy as 1, 2, 3...”
1 Connect to your existing SQL DB…
…and it is Automatically Analyzed
2 Push play and….
Work as you are used to, just add 4 lines of code in your startup class
Config hcConfig = new Config();
// Add optimized serialization Factories for Hazelcast that are generated automatically
SpeedmentHazelcastConfig.addTo(hcConfig);
HazelcastInstance hcInstance = Hazelcast.newHazelcastInstance(hcConfig);
// Tell Speedment what Hazelcast instance to use
ProjectManager.getInstance().putProperty(HazelcastInstance.class, hcInstance);
// Automatically build all Database metadata (e.g. Schema, Tables and Columns)
new TreeBuilder().build();
// Load selected data from the database into the Hazelcast maps and start tracking DB
ProjectManager.getInstance().init();
3 Start Coding with Hazelcast
No change in how maps are used
// Get the Hazelcast map for the database table "employees"
IMap<String, Employees> employeesmap =
hcInstance.getMap(EmployeesMgr.getHazelcastMapName());
// Use the Hazelcast map just as you are used to
Employees emp = employeesmap.get("10001");
Video
Customization
•  Use your own beans instead
•  Use transactions
•  Filter events using predicates
•  React on SQL events
Performance
Depends mostly on
•  The SQL server
•  Hazelcast grid configuration and
implementation
Business model
•  OpenSource coming
•  Enterprise license
Thank You!
Per-Åke Minborg
minborg@speedment.com
http://minborgsjavapot.blogspot.com/
Twitter: @Pminborg
To download:
sales@speedment.com

More Related Content

What's hot

DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
Json and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and SlickJson and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and Slick
Stephen Kemmerling
 

What's hot (20)

R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. Streams
 
Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 
Python testing-frameworks overview
Python testing-frameworks overviewPython testing-frameworks overview
Python testing-frameworks overview
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
 
R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In R
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
JDBC
JDBCJDBC
JDBC
 
[2019-07] GraphQL in depth (serverside)
[2019-07] GraphQL in depth (serverside)[2019-07] GraphQL in depth (serverside)
[2019-07] GraphQL in depth (serverside)
 
MCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The WorkMCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The Work
 
R Programming: Comparing Objects In R
R Programming: Comparing Objects In RR Programming: Comparing Objects In R
R Programming: Comparing Objects In R
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GPars
 
Json and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and SlickJson and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and Slick
 
What’s new in C# 6
What’s new in C# 6What’s new in C# 6
What’s new in C# 6
 
ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014
 

Viewers also liked

Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Hazelcast
 

Viewers also liked (6)

SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Hazelcast Essentials
Hazelcast EssentialsHazelcast Essentials
Hazelcast Essentials
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 

Similar to Applying Real-time SQL Changes in your Hazelcast Data Grid

HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Architecting JavaScript Code
Architecting JavaScript CodeArchitecting JavaScript Code
Architecting JavaScript Code
Suresh Balla
 

Similar to Applying Real-time SQL Changes in your Hazelcast Data Grid (20)

Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScript
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDB
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Painless Persistence with Realm
Painless Persistence with RealmPainless Persistence with Realm
Painless Persistence with Realm
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Architecting JavaScript Code
Architecting JavaScript CodeArchitecting JavaScript Code
Architecting JavaScript Code
 

More from Hazelcast

The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
Hazelcast
 
Hazelcast for Terracotta Users
Hazelcast for Terracotta UsersHazelcast for Terracotta Users
Hazelcast for Terracotta Users
Hazelcast
 
Extreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on ToruswareExtreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on Torusware
Hazelcast
 
JAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGsJAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGs
Hazelcast
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Hazelcast
 

More from Hazelcast (20)

Hazelcast 3.6 Roadmap Preview
Hazelcast 3.6 Roadmap PreviewHazelcast 3.6 Roadmap Preview
Hazelcast 3.6 Roadmap Preview
 
Time to Make the Move to In-Memory Data Grids
Time to Make the Move to In-Memory Data GridsTime to Make the Move to In-Memory Data Grids
Time to Make the Move to In-Memory Data Grids
 
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
 
JCache - It's finally here
JCache -  It's finally hereJCache -  It's finally here
JCache - It's finally here
 
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganShared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
 
WAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning TalkWAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning Talk
 
JAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning TalkJAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning Talk
 
Hazelcast for Terracotta Users
Hazelcast for Terracotta UsersHazelcast for Terracotta Users
Hazelcast for Terracotta Users
 
Extreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on ToruswareExtreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on Torusware
 
Big Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of HadoopBig Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of Hadoop
 
JAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGsJAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGs
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 
How to Use HazelcastMQ for Flexible Messaging and More
 How to Use HazelcastMQ for Flexible Messaging and More How to Use HazelcastMQ for Flexible Messaging and More
How to Use HazelcastMQ for Flexible Messaging and More
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open Source
 
JSR107 State of the Union JavaOne 2013
JSR107  State of the Union JavaOne 2013JSR107  State of the Union JavaOne 2013
JSR107 State of the Union JavaOne 2013
 
Jfokus - Hazlecast
Jfokus - HazlecastJfokus - Hazlecast
Jfokus - Hazlecast
 
In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014
 
In-memory Data Management Trends & Techniques
In-memory Data Management Trends & TechniquesIn-memory Data Management Trends & Techniques
In-memory Data Management Trends & Techniques
 
How to Speed up your Database
How to Speed up your DatabaseHow to Speed up your Database
How to Speed up your Database
 
Hazelcast HUGL
Hazelcast HUGLHazelcast HUGL
Hazelcast HUGL
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 

Applying Real-time SQL Changes in your Hazelcast Data Grid

  • 1. Speedment and Hazelcast For Automatic Scale out of Existing SQL Databases with Hazelcast Per-Åke Minborg www.speedment.com
  • 2. The Shared Database Challenge Database Hazelcast Hazelcast Application Hazelcast Application Hazelcast Application
  • 3. The Shared Database Challenge Database Hazelcast Hazelcast Application3:rd Party Application 3:rd Party Application 3:rd Party Application Hazelcast Application Hazelcast Application
  • 4. The Shared Database Challenge Database Speedment Hazelcast Hazelcast Application3:rd Party Application 3:rd Party Application 3:rd Party Application Hazelcast Application Hazelcast Application
  • 6. Reflects all Data with Hazelcast Exising SQL data from start System.out.println(hazelcastMap.size()); -> 300024 Inserts sql> insert into employees (emp_no, birth_date, first_name, last_name, gender, hire_date) values (10001, '1953-09-02', 'Georgi', 'Facello', 'M', '1986-06-26'); Employees emp = hazelcastMap.get("10001"); System.out.println(emp); -> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi", "last_name": "Facello", "gender": "M", "hire_date": "1986-06-26"} Updates sql> update employees set first_name="Georgi2" where emp_no=10001; Employees emp = hazelcastMap.get("10001"); System.out.println(emp); -> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi2", "last_name": "Facello", "gender": "M", "hire_date": "1986-06-26"} Deletes sql> delete from employees where emp_no = 10001; Employees emp = hazelcastMap.get("10001"); System.out.println(emp); -> null
  • 7. Works with Transactions SQL> START TRANSACTION; update employees set first_name="Duangkaew" where emp_no=10010; update salaries set salary=salary+10 where id=12322; COMMIT; // Backing hazelcast maps are updated atomically Employees emp = employeesMap.get("10001"); Salaries sal = salaryMap.get("12322");
  • 8. How to Install •  Download software •  Unzip distribution file •  Start scripts in ”bin” directory
  • 9. Generated Code §  Database triggers §  Triggerlog §  Java POJOs for each selected table §  Table manager/DAO §  Hazelcast serialization factories §  Hazelcast config support §  Relational database metadata §  Transaction support wrappers
  • 10. Database Table mysql> describe employees; +------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+----------------+ | emp_no | int(11) | NO | PRI | NULL | auto_increment | | birth_date | date | NO | | NULL | | | first_name | varchar(14) | NO | | NULL | | | last_name | varchar(16) | NO | | NULL | | | gender | enum('M','F') | NO | | NULL | | | hire_date | date | NO | | NULL | | +------------+---------------+------+-----+---------+----------------+
  • 11. POJO Representing a Row public class Employees extends Struct<Employees> implements IdentifiedDataSerializable { private Integer empNo; private Date birthDate; private String firstName; private String lastName; private String gender; private Date hireDate; // Accessors, serialization, deserialization, etc.
  • 12. @Override public int getFactoryId() { return EmployeesDataSerializableFactory.FACTORY_ID; } @Override public void writeData(ObjectDataOutput out) throws IOException { int sizeOf = (int) sizeOf(); final ByteBuffer bb = ByteBuffer.allocate(sizeOf + 4); bb.putInt(sizeOf); writeObject(bb); out.write(bb.array()); } POJO Representing a Row
  • 13. POJO Representing a Row @Override public void readData(ObjectDataInput in) throws IOException { int sizeOf = in.readInt(); final ByteBuffer bb = ByteBuffer.allocate(sizeOf); in.readFully(bb.array()); try { readObject(bb); } catch (final ClassNotFoundException cnfe) { _logger.error(cnfe.getMessage(), cnfe); } } }
  • 14. Manager/DAO Representing a Table public class EmployeesMgr extends Manager<Employees> { @Override public Employees getNewObjectInstance() { return new Employees(); } // insert, update, delete, finders, size, etc.
  • 15. Manager/DAO Representing a Table @Override public void add(final Employees employees) { addHazelcast(employees); } @Override public void remove(final Employees employees) { removeHazelcast(employees); } }
  • 16. Manager/DAO Representing a Table protected void addHazelcast(final Employees employees) { final String _key = employees._getPrimaryKeyString(); final TransactionalMap<String, Employees> transactionMap = getHazelcastTransactionalMap(); if (transactionMap != null) { transactionMap.put(_key, employees); } else { hcPrimaryKeyMap.put(_key, employees); } }
  • 17. DataSerializableFactory per Table public class EmployeesDataSerializableFactoryBase implements DataSerializableFactory { public static final int FACTORY_ID = 1221169916; public static final int EMPLOYEES_ID = 0; @Override public IdentifiedDataSerializable create(int typeId) { return EmployeesMgr.getInstance().getNewObjectInstance(); } }
  • 18. Configuration Support Class (One) public class SpeedmentHazelcastConfig{ public static void addTo(final Config config) { addTo(config.getSerializationConfig()); } public static void addTo(final ClientConfig config) { addTo(config.getSerializationConfig()); } public static void addTo(final SerializationConfig serializationConfig) { serializationConfig.addDataSerializableFactory( DepartmentsDataSerializableFactory.FACTORY_ID, new DepartmentsDataSerializableFactory()); serializationConfig.addDataSerializableFactory( DeptManagerDataSerializableFactory.FACTORY_ID, new DeptManagerDataSerializableFactory()); serializationConfig.addDataSerializableFactory( EmployeesDataSerializableFactory.FACTORY_ID, new EmployeesDataSerializableFactory()); } }
  • 19. Transaction Support Classes public class HazelcastTransactionHandlerFactory implements TransactionHandlerFactory { private final HazelcastInstance hazelcastInstance; private final TransactionOptions transactionOptions; public HazelcastTransactionHandlerFactory(HazelcastInstance hazelcastInstance, TransactionOptions transactionOptions) { this.hazelcastInstance = hazelcastInstance; this.transactionOptions = transactionOptions; } @Override public TransactionHandler newTransactionHandler() { final TransactionContext context = hazelcastInstance.newTransactionContext(transactionOptions);; return new HazelcastTransactionHandler(context); } }
  • 20. Transaction Support Classes public class HazelcastTransactionHandler implements TransactionHandler { private final TransactionContext context; public HazelcastTransactionHandler(TransactionContext context) { this.context = context; } . . . }
  • 21. Transaction Support Classes @Override public void begin() { context.beginTransaction(); } @Override public void commit() { context.commitTransaction(); } @Override public void rollback() { context.rollbackTransaction(); } public TransactionContext getContext() { return context; }
  • 22. How do you use it? “Easy as 1, 2, 3...”
  • 23. 1 Connect to your existing SQL DB…
  • 24. …and it is Automatically Analyzed
  • 25. 2 Push play and….
  • 26. Work as you are used to, just add 4 lines of code in your startup class Config hcConfig = new Config(); // Add optimized serialization Factories for Hazelcast that are generated automatically SpeedmentHazelcastConfig.addTo(hcConfig); HazelcastInstance hcInstance = Hazelcast.newHazelcastInstance(hcConfig); // Tell Speedment what Hazelcast instance to use ProjectManager.getInstance().putProperty(HazelcastInstance.class, hcInstance); // Automatically build all Database metadata (e.g. Schema, Tables and Columns) new TreeBuilder().build(); // Load selected data from the database into the Hazelcast maps and start tracking DB ProjectManager.getInstance().init(); 3 Start Coding with Hazelcast
  • 27. No change in how maps are used // Get the Hazelcast map for the database table "employees" IMap<String, Employees> employeesmap = hcInstance.getMap(EmployeesMgr.getHazelcastMapName()); // Use the Hazelcast map just as you are used to Employees emp = employeesmap.get("10001");
  • 28. Video
  • 29. Customization •  Use your own beans instead •  Use transactions •  Filter events using predicates •  React on SQL events
  • 30. Performance Depends mostly on •  The SQL server •  Hazelcast grid configuration and implementation
  • 31. Business model •  OpenSource coming •  Enterprise license