SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Roman Pichlík

Mehr von 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
 

Kürzlich hochgeladen

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
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
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Kürzlich hochgeladen (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
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
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

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