SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
MongoDB
                      JBoss User Group Brno




                                      dagi@gooddata.com

Thursday 3 May 2012
About me
                      •   Roman Pichlík

                      •   GoodData

                      •   CZJUG

                      •   CZ Podcast

                      •   Follow me on Twitter

                          •   @_dagi



Thursday 3 May 2012
Agenda

                      • What’s wrong...
                      • Demo
                      • Using MongoDB in Java
                      • MongoDB deployment in GoodData
                      • Q&A

Thursday 3 May 2012
A typical java app with
                             RDBMS
                                      Web Layer
                         Domain
                                  Business Logic Layer
                         model
                                   Data Access Layer




Thursday 3 May 2012
A typical java app with
                             RDBMS
                                      Web Layer
                         Domain
                                  Business Logic Layer
                         model
                                   Data Access Layer




Thursday 3 May 2012
A typical java app with
                             RDBMS
                                                        Web Layer
                             Domain
                                                    Business Logic Layer
                             model
      am
            eta
               dat
                                                     Data Access Layer
                  a fo
                      rm
                        app
                            ing
                                to
                                     RD
                                       BM
                                         S sc
                                             hem
                                                a




Thursday 3 May 2012
A typical java app with
                             RDBMS
                                                        Web Layer
                             Domain
                                                    Business Logic Layer
                             model
      am
            eta
               dat
                                                     Data Access Layer
                  a fo
                      rm
                        app                                                                      al
                            ing                                                          e lation
                                to                                               b ject/R sa
                                     RD                                  ic for O ice ver
                                       BM                           k mag on and v
                                         S sc
                                             hem              a blac versi
                                                a                   con




Thursday 3 May 2012
A typical java app with
                             RDBMS
                                                        Web Layer
                             Domain
                                                    Business Logic Layer
                             model
      am
            eta
               dat
                                                     Data Access Layer
                  a fo
                      rm
                        app                                                                      al
                            ing                                                          e lation
                                to                                               b ject/R sa
                                     RD                                  ic for O ice ver
                                       BM                           k mag on and v
                                         S sc
                                             hem              a blac versi
                                                a                   con

                                                                         and transactions...


Thursday 3 May 2012
Data Access Layer




Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Data Access Layer
                                   CRUD interface




Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Data Access Layer
                                   CRUD interface

                      Persistence context logic (queries, merge...)




Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Data Access Layer
                                   CRUD interface

                      Persistence context logic (queries, merge...)

                                  Spring ORM Bridge




Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Data Access Layer
                                   CRUD interface

                      Persistence context logic (queries, merge...)

                                  Spring ORM Bridge

                           ORM framework (Hibernate/JPA)



Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Data Access Layer
                                   CRUD interface

                      Persistence context logic (queries, merge...)
  Why the hell it’s so complicated?!
                                  Spring ORM Bridge

                           ORM framework (Hibernate/JPA)



Thursday 3 May 2012

It’s not only complicated on this picture -> required 3rd party libraries on classpath
Abstraction faux pas

                      • We get used to live/think in Object world
                      • We store data in RDBMS world
                      • We build a bridge between Object/
                        RDBMS worlds
                      • The bridge (ORM) is very complicated

Thursday 3 May 2012

How many of you know patterns like Open Session in View, DTO?
How many of you know the difference between first and second level cache?
How many of you know the difference between Session#load and Session#get method?
Time for MongoDB



Thursday 3 May 2012
MongoDB
                      • Document oriented database
                      • Schema less
                      • Driver API
                      • NoSQL but Query friendly
                      • Open source
                       • AGPL server, Apache 2.0 driver
Thursday 3 May 2012
Data organization




Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                                   RDBMS
                                      table
                                        Fruit
                                         id
                                       weight
                                       color
                                   discriminator
                                      country
                                     curvature




Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                RDBMS
                      collection           table
                        Fruit                Fruit
                      Document                id
                                            weight
                                            color
                                        discriminator
                                           country
                                          curvature




Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                RDBMS
                      collection           table
                        Fruit                Fruit
                      Document                id
                                            weight
                                            color
                                        discriminator
                                           country
                                          curvature




Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                                       RDBMS
                      collection                                      table
                        Fruit                                         Fruit
                      Document                                         id
                                                                     weight
                                                                     color
                                                                 discriminator
                                                                    country
                                                                   curvature


                                         id   discriminator   color    weight    country   curvature
                                   row   1       apple        red       10         cz        null
                                         2      banana        null      5.1        br          3




Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                                           RDBMS
                      collection                                          table
                        Fruit                                             Fruit
                      Document                                             id
                                                                         weight
                      document
                                                                         color
               {                                                     discriminator
                  "_id":"1",                                            country
                  "apple":{                                            curvature
                     "weight":10,
                     "country":"cz",
                     "color":"red"           id   discriminator   color    weight    country   curvature
                  }
               }                       row   1       apple        red       10         cz        null
                                             2      banana        null      5.1        br          3
               {
                  "_id":"2",
                  "banana":{
                     "weight":5.1,
                     "country":"br",
                     "curvature":3
                  }
               }

Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                                           RDBMS
                      collection                                          table
                        Fruit                                             Fruit
                      Document                                             id
                                                                         weight
                      document
                                                                         color
               {                                                     discriminator
                  "_id":"1",                                            country
                  "apple":{                                            curvature
                     "weight":10,
                     "country":"cz",
                     "color":"red"           id   discriminator   color    weight    country   curvature
                  }
               }                       row   1       apple        red       10         cz        null
                                             2      banana        null      5.1        br          3
               {
                  "_id":"2",
                  "banana":{
                     "weight":5.1,
                     "country":"br",
                     "curvature":3
                  }
               }

Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Data organization
                 MongoDB                                                  RDBMS
                      collection                                                 table
                        Fruit                                                    Fruit
                      Document                                                    id
                                                                                weight
                      document
                                                                                color
               {                                                            discriminator
                  "_id":"1",                                                   country
                  "apple":{                                                   curvature
                     "weight":10,
                     "country":"cz",
                     "color":"red"                  id   discriminator   color    weight    country   curvature
                  }
               }                              row   1       apple        red       10         cz        null
                                                    2      banana        null      5.1        br          3
               {
                  "_id":"2",                              column
                  "banana":{
                     "weight":5.1,     field
                     "country":"br",
                     "curvature":3
                  }
               }

Thursday 3 May 2012

document - JSON
schemaless (documents, fields)
Fruit demo :-)



Thursday 3 May 2012
> use fruitdb
                                    change/create DB
  switched to db fruitdb
                                          insert document
  > db.createCollection("fruit");
  { "ok" : 1 }

  > db.fruit.insert({apple:{weight:10, country:"cz", color:"red"}});

  > db.fruit.findOne();                get first document
  { "_id" : ObjectId("4fa0f21591d1fb43c578fa26"), "apple" : { "color" :
  "red", "country" : "cz", "weight" : 10 } }

  > db.fruit.insert({banana:{weight:5.1, country: "br", curvature:3}});

  > db.fruit.update({"apple.color":"green"}, {$set:
  {"apple.color":"red"}});                      update document
  > db.fruit.remove({"_id":"4fa0f3a791d1fb43c578fa27"})

  > db.fruit.find({"apple.color":"red"});     remove document
  { "_id" : ObjectId("4fa0f21591d1fb43c578fa26"), "apple" : { "color" :
  "red", "country" : "cz", "weight" : 10 } }

                                                  find document
Thursday 3 May 2012
Using MongoDB in Java
                  MongoDB                      Java Application
                        BSON                         Web Layer
                                      Domain
                      JSON document            Business Logic Layer
         {                            model
            "_id":"...",
            "apple":{
                                                Data Access Layer
               "weight":10,
               "country":"cz",
               "color":"red"
                                       BSON API          Auth.
            }
         }
                                             MongoDB driver
                                        Failover     Connectivity

Thursday 3 May 2012
Using MongoDB in Java
                      Mongo m = new Mongo("localhost" , 27017 );

                      DB db = m.getDB( "fruitdb" );
                      DBCollection coll = db.getCollection("fruit");

                      BasicDBObject doc = new BasicDBObject();
                      BasicDBObject apple = new BasicDBObject();
                      apple.put("weight", 10);
                      apple.put("country", "cz");
                      apple.put("color", "red");
                      doc.put("apple", apple);

                      fruit.insert(doc);




Thursday 3 May 2012
Sweet MongoDB
                      •   Thin Data Access Layer

                          •   No magic behind the
                              scene

                      •   Flexible

                          •   schemaless

                          •   new document types

                          •   new collections

                          •   No Alter DDL
Thursday 3 May 2012
Architecture impact
                      • No transactions
                       • only atomic update on document level
                       • atomic FindAndUpdate operation
                      • No constraints
                       • application logic handles data
                          inconsistency
                      • Self sufficient documents over Joins
Thursday 3 May 2012
                       • redundancy
MongoDB cluster in GoodData




                                                  Sync. write, Master + Slave
                      •   GoodData platform




                                                                                                          No slave reads
                          hosted on Amazon WS                                           Client

                      •   3-node

                      •   Journal enabled                                               Master
                      •   EBS used for data
                                                                                    replication
                          •   backup/restore
                                                                                Slave             Slave
                      •   Application specific
                          backup/restore

Thursday 3 May 2012

* Master elected automatically on start or when the previous one goes down
* Master writes to journal -> Ops log replicated to slaves
Thank you

                      •   Join us and work with MongoDB ;-)

                      •   http://www.gooddata.com/about/careers

                      •   Q&A




Thursday 3 May 2012

Más contenido relacionado

Similar a MongoDB for Java Developers

Ebs architecture con9036_pdf_9036_0001
Ebs architecture con9036_pdf_9036_0001Ebs architecture con9036_pdf_9036_0001
Ebs architecture con9036_pdf_9036_0001jucaab
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptmartinlippert
 
Cloudfoundry architecture
Cloudfoundry architectureCloudfoundry architecture
Cloudfoundry architectureRamnivas Laddad
 
Google App Engine Update 2012
Google App Engine Update 2012Google App Engine Update 2012
Google App Engine Update 2012David Chandler
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenPatrick Chanezon
 
NIG系統報表開發指南
NIG系統報表開發指南NIG系統報表開發指南
NIG系統報表開發指南Guo Albert
 
Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationIMC Institute
 
Scality, Cloud Storage pour Zimbra
Scality, Cloud Storage pour ZimbraScality, Cloud Storage pour Zimbra
Scality, Cloud Storage pour ZimbraAntony Barroux
 
Moving from Relational to Document Store
Moving from Relational to Document StoreMoving from Relational to Document Store
Moving from Relational to Document StoreGraham Tackley
 
Why we chose mongodb for guardian.co.uk
Why we chose mongodb for guardian.co.ukWhy we chose mongodb for guardian.co.uk
Why we chose mongodb for guardian.co.ukGraham Tackley
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05Ankit Dubey
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05JONDHLEPOLY
 
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...Channy Yun
 
JBoye Presentation: WCM Trends for 2010
JBoye Presentation: WCM Trends for 2010JBoye Presentation: WCM Trends for 2010
JBoye Presentation: WCM Trends for 2010David Nuescheler
 
Graph Databases, The Web of Data Storage Engines
Graph Databases, The Web of Data Storage EnginesGraph Databases, The Web of Data Storage Engines
Graph Databases, The Web of Data Storage EnginesPere Urbón-Bayes
 
20130204 graph to-pacer-xml
20130204 graph to-pacer-xml20130204 graph to-pacer-xml
20130204 graph to-pacer-xmlDavid Colebatch
 

Similar a MongoDB for Java Developers (20)

Ebs architecture con9036_pdf_9036_0001
Ebs architecture con9036_pdf_9036_0001Ebs architecture con9036_pdf_9036_0001
Ebs architecture con9036_pdf_9036_0001
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScript
 
Cloudfoundry architecture
Cloudfoundry architectureCloudfoundry architecture
Cloudfoundry architecture
 
Google App Engine Update 2012
Google App Engine Update 2012Google App Engine Update 2012
Google App Engine Update 2012
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
 
NIG系統報表開發指南
NIG系統報表開發指南NIG系統報表開發指南
NIG系統報表開發指南
 
Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web Application
 
No Sql
No SqlNo Sql
No Sql
 
Scality, Cloud Storage pour Zimbra
Scality, Cloud Storage pour ZimbraScality, Cloud Storage pour Zimbra
Scality, Cloud Storage pour Zimbra
 
Moving from Relational to Document Store
Moving from Relational to Document StoreMoving from Relational to Document Store
Moving from Relational to Document Store
 
Why we chose mongodb for guardian.co.uk
Why we chose mongodb for guardian.co.ukWhy we chose mongodb for guardian.co.uk
Why we chose mongodb for guardian.co.uk
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Ra business intelligence 0.1
Ra business intelligence 0.1Ra business intelligence 0.1
Ra business intelligence 0.1
 
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...
The Construction of the Internet Geological Data System Using WWW+Java+DB Tec...
 
Ordbms
OrdbmsOrdbms
Ordbms
 
JBoye Presentation: WCM Trends for 2010
JBoye Presentation: WCM Trends for 2010JBoye Presentation: WCM Trends for 2010
JBoye Presentation: WCM Trends for 2010
 
Graph Databases, The Web of Data Storage Engines
Graph Databases, The Web of Data Storage EnginesGraph Databases, The Web of Data Storage Engines
Graph Databases, The Web of Data Storage Engines
 
Ta3
Ta3Ta3
Ta3
 
20130204 graph to-pacer-xml
20130204 graph to-pacer-xml20130204 graph to-pacer-xml
20130204 graph to-pacer-xml
 

Más de Roman Pichlík

Más de Roman Pichlík (16)

Cynycal software
Cynycal softwareCynycal software
Cynycal software
 
App Design Architecture
App Design ArchitectureApp Design Architecture
App Design Architecture
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring Transactions
Spring TransactionsSpring Transactions
Spring Transactions
 
Spring Testing
Spring TestingSpring Testing
Spring Testing
 
Spring J2EE
Spring J2EESpring J2EE
Spring J2EE
 
Spring ioc-advanced
Spring ioc-advancedSpring ioc-advanced
Spring ioc-advanced
 
Spring ioc
Spring iocSpring ioc
Spring ioc
 
Spring introduction
Spring introductionSpring introduction
Spring introduction
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring dao
Spring daoSpring dao
Spring dao
 
Spring aop
Spring aopSpring aop
Spring aop
 
Spring Web Services
Spring Web ServicesSpring Web Services
Spring Web Services
 
Nosql from java developer pov
Nosql from java developer povNosql from java developer pov
Nosql from java developer pov
 
Spring framework - J2EE S Lidskou Tvari
Spring framework - J2EE S Lidskou TvariSpring framework - J2EE S Lidskou Tvari
Spring framework - J2EE S Lidskou Tvari
 
Dependency Injection Frameworky
Dependency Injection FrameworkyDependency Injection Frameworky
Dependency Injection Frameworky
 

Último

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

MongoDB for Java Developers

  • 1. MongoDB JBoss User Group Brno dagi@gooddata.com Thursday 3 May 2012
  • 2. About me • Roman Pichlík • GoodData • CZJUG • CZ Podcast • Follow me on Twitter • @_dagi Thursday 3 May 2012
  • 3. Agenda • What’s wrong... • Demo • Using MongoDB in Java • MongoDB deployment in GoodData • Q&A Thursday 3 May 2012
  • 4. A typical java app with RDBMS Web Layer Domain Business Logic Layer model Data Access Layer Thursday 3 May 2012
  • 5. A typical java app with RDBMS Web Layer Domain Business Logic Layer model Data Access Layer Thursday 3 May 2012
  • 6. A typical java app with RDBMS Web Layer Domain Business Logic Layer model am eta dat Data Access Layer a fo rm app ing to RD BM S sc hem a Thursday 3 May 2012
  • 7. A typical java app with RDBMS Web Layer Domain Business Logic Layer model am eta dat Data Access Layer a fo rm app al ing e lation to b ject/R sa RD ic for O ice ver BM k mag on and v S sc hem a blac versi a con Thursday 3 May 2012
  • 8. A typical java app with RDBMS Web Layer Domain Business Logic Layer model am eta dat Data Access Layer a fo rm app al ing e lation to b ject/R sa RD ic for O ice ver BM k mag on and v S sc hem a blac versi a con and transactions... Thursday 3 May 2012
  • 9. Data Access Layer Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 10. Data Access Layer CRUD interface Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 11. Data Access Layer CRUD interface Persistence context logic (queries, merge...) Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 12. Data Access Layer CRUD interface Persistence context logic (queries, merge...) Spring ORM Bridge Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 13. Data Access Layer CRUD interface Persistence context logic (queries, merge...) Spring ORM Bridge ORM framework (Hibernate/JPA) Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 14. Data Access Layer CRUD interface Persistence context logic (queries, merge...) Why the hell it’s so complicated?! Spring ORM Bridge ORM framework (Hibernate/JPA) Thursday 3 May 2012 It’s not only complicated on this picture -> required 3rd party libraries on classpath
  • 15. Abstraction faux pas • We get used to live/think in Object world • We store data in RDBMS world • We build a bridge between Object/ RDBMS worlds • The bridge (ORM) is very complicated Thursday 3 May 2012 How many of you know patterns like Open Session in View, DTO? How many of you know the difference between first and second level cache? How many of you know the difference between Session#load and Session#get method?
  • 17. MongoDB • Document oriented database • Schema less • Driver API • NoSQL but Query friendly • Open source • AGPL server, Apache 2.0 driver Thursday 3 May 2012
  • 18. Data organization Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 19. Data organization RDBMS table Fruit id weight color discriminator country curvature Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 20. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight color discriminator country curvature Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 21. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight color discriminator country curvature Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 22. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight color discriminator country curvature id discriminator color weight country curvature row 1 apple red 10 cz null 2 banana null 5.1 br 3 Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 23. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight document color { discriminator    "_id":"1", country    "apple":{ curvature       "weight":10,       "country":"cz",       "color":"red" id discriminator color weight country curvature    } } row 1 apple red 10 cz null 2 banana null 5.1 br 3 {    "_id":"2",    "banana":{       "weight":5.1,       "country":"br",       "curvature":3    } } Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 24. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight document color { discriminator    "_id":"1", country    "apple":{ curvature       "weight":10,       "country":"cz",       "color":"red" id discriminator color weight country curvature    } } row 1 apple red 10 cz null 2 banana null 5.1 br 3 {    "_id":"2",    "banana":{       "weight":5.1,       "country":"br",       "curvature":3    } } Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 25. Data organization MongoDB RDBMS collection table Fruit Fruit Document id weight document color { discriminator    "_id":"1", country    "apple":{ curvature       "weight":10,       "country":"cz",       "color":"red" id discriminator color weight country curvature    } } row 1 apple red 10 cz null 2 banana null 5.1 br 3 {    "_id":"2", column    "banana":{       "weight":5.1, field       "country":"br",       "curvature":3    } } Thursday 3 May 2012 document - JSON schemaless (documents, fields)
  • 27. > use fruitdb change/create DB switched to db fruitdb insert document > db.createCollection("fruit"); { "ok" : 1 } > db.fruit.insert({apple:{weight:10, country:"cz", color:"red"}}); > db.fruit.findOne(); get first document { "_id" : ObjectId("4fa0f21591d1fb43c578fa26"), "apple" : { "color" : "red", "country" : "cz", "weight" : 10 } } > db.fruit.insert({banana:{weight:5.1, country: "br", curvature:3}}); > db.fruit.update({"apple.color":"green"}, {$set: {"apple.color":"red"}}); update document > db.fruit.remove({"_id":"4fa0f3a791d1fb43c578fa27"}) > db.fruit.find({"apple.color":"red"}); remove document { "_id" : ObjectId("4fa0f21591d1fb43c578fa26"), "apple" : { "color" : "red", "country" : "cz", "weight" : 10 } } find document Thursday 3 May 2012
  • 28. Using MongoDB in Java MongoDB Java Application BSON Web Layer Domain JSON document Business Logic Layer { model    "_id":"...",    "apple":{ Data Access Layer       "weight":10,       "country":"cz",       "color":"red" BSON API Auth.    } } MongoDB driver Failover Connectivity Thursday 3 May 2012
  • 29. Using MongoDB in Java Mongo m = new Mongo("localhost" , 27017 ); DB db = m.getDB( "fruitdb" ); DBCollection coll = db.getCollection("fruit"); BasicDBObject doc = new BasicDBObject(); BasicDBObject apple = new BasicDBObject(); apple.put("weight", 10); apple.put("country", "cz"); apple.put("color", "red"); doc.put("apple", apple); fruit.insert(doc); Thursday 3 May 2012
  • 30. Sweet MongoDB • Thin Data Access Layer • No magic behind the scene • Flexible • schemaless • new document types • new collections • No Alter DDL Thursday 3 May 2012
  • 31. Architecture impact • No transactions • only atomic update on document level • atomic FindAndUpdate operation • No constraints • application logic handles data inconsistency • Self sufficient documents over Joins Thursday 3 May 2012 • redundancy
  • 32. MongoDB cluster in GoodData Sync. write, Master + Slave • GoodData platform No slave reads hosted on Amazon WS Client • 3-node • Journal enabled Master • EBS used for data replication • backup/restore Slave Slave • Application specific backup/restore Thursday 3 May 2012 * Master elected automatically on start or when the previous one goes down * Master writes to journal -> Ops log replicated to slaves
  • 33. Thank you • Join us and work with MongoDB ;-) • http://www.gooddata.com/about/careers • Q&A Thursday 3 May 2012