Using Spring and MongoDB with Cloud Foundry Chris Harris, Architect
Spring Data
Data Access Challenge #1: Scale Horizontally
Data Access Challenge #2: Heterogeneous data access needs
New demands on data access ... until we needed inexpensive horizontal scaling for some large web based applications ... ... and we needed to deploy our apps in the cloud ... image courtesy of Bitcurrent
NoSQL offers several data store categories Column Key-Value Document Graph
Spring Framework built-in data access support Transaction abstractions Common data access exception hierarchy JDBC - JdbcTemplate ORM - Hibernate, JPA support OXM - Object to XML mapping Serializer/Deserializer strategies (Spring 3.0) Cache support (Spring 3.1)
Spring Data Key-value Spring Data Document Spring Data Graph Spring Data Column Spring Data Blob Spring Data JPA Repository / JDBC Extensions Spring Gemfire / Spring Hadoop ... Grails i N c O n S e Q uentia L
Spring Data Building Blocks Low level data access APIs MongoTemplate, RedisTemplate ... Object Mapping (Java and GORM) Cross Store Persistence Programming model Generic Repository support Productivity support in Roo and Grails
Spring MongoDB
Spring Data Document Mongo MongoTemplate MongoConverter interface for mapping Mongo documents SimpleMongoConverter for basic POJO mapping support Leverage Spring 3.0 TypeConverters and SpEL Exception translation Advanced Mapping Annotation based (@Document, @Id, @DbRef) MongoRepository Built on Hades support for JPA Repositories
Simple Domain Class
Mongo Template Direct Usage of the Mongo Template:
Generic Repository Interface for generic CRUD operations on a repository for a specific type
Paging and Sorting Repository Extends “ CrudRepository ” Usage: Paging and Sorting Repository:
Custom Repository Custom Repository: Keywords : Keyword Sample Logical result GreaterThan findByAgeGreaterThan(int age) {"age" : { "$gt" : age}} LessThan findByAgeLessThan(int age) {"age" : { "$lt" : age}} Between findByAgeBetween(int from, int to) {"age" : { "$gt" : from, "$lt" : to}} NotNull findByFirstnameNotNull() { ” firstname" : {" $ne" : null}} Null findByFirstnameNull() { ” firstname" : null} Like findByFirstnameLike(String name) " firstname " : firstname } ( regex ) etc….
Cross Store
JPA and MongoDB JPA “Customer” with a “ SurveyInfo ” Document
Using a Cross-Store Saving a Customer with a SurveryInfo Mongo Document:
Cloud Foundry
Choice of clouds Cloud Provider Interface Application Service Interface Data Services Private Clouds Public Clouds Micro Clouds .js Other Services Msg Services .COM …
Cloud Foundry MongoDB Demo

Using Spring Data and MongoDB with Cloud Foundry

  • 1.
    Using Spring andMongoDB with Cloud Foundry Chris Harris, Architect
  • 2.
  • 3.
    Data Access Challenge#1: Scale Horizontally
  • 4.
    Data Access Challenge#2: Heterogeneous data access needs
  • 5.
    New demands ondata access ... until we needed inexpensive horizontal scaling for some large web based applications ... ... and we needed to deploy our apps in the cloud ... image courtesy of Bitcurrent
  • 6.
    NoSQL offers severaldata store categories Column Key-Value Document Graph
  • 7.
    Spring Framework built-indata access support Transaction abstractions Common data access exception hierarchy JDBC - JdbcTemplate ORM - Hibernate, JPA support OXM - Object to XML mapping Serializer/Deserializer strategies (Spring 3.0) Cache support (Spring 3.1)
  • 8.
    Spring Data Key-valueSpring Data Document Spring Data Graph Spring Data Column Spring Data Blob Spring Data JPA Repository / JDBC Extensions Spring Gemfire / Spring Hadoop ... Grails i N c O n S e Q uentia L
  • 9.
    Spring Data BuildingBlocks Low level data access APIs MongoTemplate, RedisTemplate ... Object Mapping (Java and GORM) Cross Store Persistence Programming model Generic Repository support Productivity support in Roo and Grails
  • 10.
  • 11.
    Spring Data DocumentMongo MongoTemplate MongoConverter interface for mapping Mongo documents SimpleMongoConverter for basic POJO mapping support Leverage Spring 3.0 TypeConverters and SpEL Exception translation Advanced Mapping Annotation based (@Document, @Id, @DbRef) MongoRepository Built on Hades support for JPA Repositories
  • 12.
  • 13.
    Mongo Template DirectUsage of the Mongo Template:
  • 14.
    Generic Repository Interface for generic CRUD operations on a repository for a specific type
  • 15.
    Paging and SortingRepository Extends “ CrudRepository ” Usage: Paging and Sorting Repository:
  • 16.
    Custom Repository Custom Repository: Keywords : Keyword Sample Logical result GreaterThan findByAgeGreaterThan(int age) {"age" : { "$gt" : age}} LessThan findByAgeLessThan(int age) {"age" : { "$lt" : age}} Between findByAgeBetween(int from, int to) {"age" : { "$gt" : from, "$lt" : to}} NotNull findByFirstnameNotNull() { ” firstname" : {" $ne" : null}} Null findByFirstnameNull() { ” firstname" : null} Like findByFirstnameLike(String name) " firstname " : firstname } ( regex ) etc….
  • 17.
  • 18.
    JPA and MongoDB JPA “Customer” with a “ SurveyInfo ” Document
  • 19.
    Using a Cross-StoreSaving a Customer with a SurveryInfo Mongo Document:
  • 20.
  • 21.
    Choice of cloudsCloud Provider Interface Application Service Interface Data Services Private Clouds Public Clouds Micro Clouds .js Other Services Msg Services .COM …
  • 22.

Editor's Notes

  • #4 Oracle RAC clustering is very expensive. $70K/CPU according to list. Even at ½ the cost, it’s still really expensive to build out a horizontal data access grid.
  • #5 The amount of log data amassed in Facebook’s operations is staggering. Rothschild said Facebook manages more than 25 terabytes of data per day in logging data, which he said was the equivalent of about 1,000 times the volume of mail delivered daily by the U.S. Postal Service. BASE (basically available, soft state, eventually consistent)