SlideShare ist ein Scribd-Unternehmen logo
1 von 86
Downloaden Sie, um offline zu lesen
Using Spring with NoSQL databases
Chris Richardson,
Author of POJOs in Action, Founder of the original CloudFoundry.com
  @crichardson chris.richardson@springsource.com http://plainoldobjects.com/
Presentation goal
 NoSQL databases: what, why and
            how
  How Spring Data simplifies the
development of NoSQL applications
About Chris
(About Chris)
About Chris()
About Chris
About Chris




http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/
vmc push About-Chris

      Developer Advocate




Signup at http://cloudfoundry.com
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
Relational databases are great...

•   SQL                                •   Well supported

    •   High-level                         •   JDBC

    •   Sorting                            •   Hibernate/JPA

    •   Aggregation                        •   Spring

•   ACID semantics                     •   Well understood

                                           •   Developers

                                           •   Operators
... but they have limitations

•   Object/relational impedance mismatch

•   Complicated to map rich domain model to relational schema

•   Difficult to handle semi-structured data, e.g. varying attributes

•   Schema changes

•   Extremely difficult/impossible to scale

•   Poor performance for some use cases
Solution: Spend Money



                                                                               OR
http://upload.wikimedia.org/wikipedia/commons/e/e5/Rising_Sun_Yacht.JPG




•    Hire more DevOps
•    Use application-level sharding
•    Build your own middleware
•    …

                                                                                    http://www.trekbikes.com/us/en/bikes/road/race_performance/madone_5_series/madone_5_2/#
Solution: Use NoSQL
           Benefits
•   Higher performance
•   Higher scalability
•   Richer data-model
•   Schema-less
                               Drawbacks
                         • Limited transactions
                         • Relaxed consistency
                         • Unconstrained data
Growing in popularity…
But don’t get too excited
Solution: Use NewSQL
• Relational databases with SQL and ACID transactions
                                         AND
• New and improved architecture - designed for modern hardware
• Radically better scalability and performance

• NewSQL vendors: Gemfire/SQLFire, VoltDB, ...
Future = multi-paradigm data storage for
         enterprise applications




      IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
Redis

•   Advanced key-value store                                K1    V1
•   Written in C
                                                            K2    V2
•   Very fast, e.g. 100K reqs/sec

•   Optional persistence                                    ...   ...
•   Transactions with optimistic locking

•   Master-slave replication

•   Sharding using client-side consistent hashing
Using Redis (via CLI)
Datatypes:         redis 127.0.0.1:6379> set foo 1
                   OK
•Strings           redis 127.0.0.1:6379> get foo
•Hashes            "1"
•Maps              redis 127.0.0.1:6379> sadd myset a
•Lists             (integer) 1
•Sets              redis 127.0.0.1:6379> sadd myset b
                   (integer) 1
•Sorted sets       redis 127.0.0.1:6379> smembers myset
                   1) "a"
                   2) "b"
                   redis 127.0.0.1:6379> srem myset a
                   (integer) 1
                   redis 127.0.0.1:6379> smembers myset
                   1) "b"
Redis use cases
•   Replacement for Memcached                    •   Handling tasks that overload an RDBMS
    •   Session state                                •   Hit counts - INCR
    •   Cache of data retrieved from system of       •   Most recent N items - LPUSH and LTRIM
        record (SOR)
                                                     •   Randomly selecting an item –
•   Replica of SOR for queries needing high-             SRANDMEMBER
    performance
                                                     •   Queuing – Lists with LPOP, RPUSH, ….
                                                     •   High score tables – Sorted sets and ZINCRBY
                                                     •   …
MongoDB

•   Document-oriented database                  •   Geospatial queries

    •   JSON-style documents: objects, lists,   •   Grid FS provides file storage
        primitives
                                                •   Very fast, asynchronous writes
    •   Schema-less
                                                •   Highly scalable and available
•   Transaction = update of a single
    document

•   Rich query language for dynamic queries
Data model = Binary JSON documents
                                  Server

                      Database: Food To Go
                    Collection: Restaurants
   {
       "name" : "TGI Fridays",
       "type" : ”American",
       "serviceArea" : [
          "94619",
          "94618"
       ],                                             Sequence of
       "openingHours" : [                             bytes on disk
          {                                           è fast i/o
             "dayOfWeek" : "Wednesday",
             "open" : 1730,
             "close" : 2230
          }
       ],
       "_id" : ObjectId("4bddc2f49d1505567c6220a0")
   }
MongoDB CLI
> r = {name: 'Ajanta'}
> db.restaurants.save(r)
> r
{ "_id" : ObjectId("4e555dd9646e338dca11710c"), "name" : "Ajanta" }
> r = db.restaurants.findOne({name:"Ajanta"})
{ "_id" : ObjectId("4e555dd9646e338dca11710c"), "name" : "Ajanta" }
> r.type= "Indian”
> db.restaurants.save(r)
> db.restaurants.update({name:"Ajanta"},
                    {$set: {name:"Ajanta Restaurant"},
                     $push: { menuItems: {name: "Chicken Vindaloo"}}})
> db.restaurants.find()
{ "_id" : ObjectId("4e555dd9646e338dca11710c"), "menuItems" : [ { "name" :
  "Chicken Vindaloo" } ], "name" : "Ajanta Restaurant", "type" : "Indian" }
> db.restaurants.remove(r.id)
MongoDB query by example
{
    serviceArea:"94619",
                                               Find a restaurant that
    openingHours: {                            serves the 94619 zip
      $elemMatch : {                           code and is open at 6pm
           "dayOfWeek" : "Monday",
           "open": {$lte: 1800},               on a Monday
           "close": {$gte: 1800}
       }
    }
}



DBCursor cursor = collection.find(qbeObject);
while (cursor.hasNext()) {
   DBObject o = cursor.next();
   …
 }
Scaling MongoDB
                Shard 1                                     Shard 2
                                Mongod                                     Mongod
                                (replica)                                  (replica)



                     Mongod           Mongod                     Mongod          Mongod
                    (master)          (replica)                 (master)         (replica)




Config Server


                                                  Mongos
  mongod                                           Mongos



  mongod


                                                  Client
  mongod
MongoDB use cases

•   Use cases                           •   Who is using it?

    •   High volume writes                  •   Shutterfly, Foursquare

    •   Complex data                        •   Bit.ly Intuit

    •   Semi-structured data                •   SourceForge, NY Times

                                            •   GILT Groupe, Evite,

                                            •   SugarCRM
Other NoSQL databases
Type                                                          Examples

Extensible columns/Column-oriented                            Hbase
                                                                      e
                                                              SimpleDB, DynamoDB
                                                                  r it
                                                              avo
                                                              Cassandra
                                                           r f
                                                    you
Graph                                       Neo4j
                                                  t
                                           t ou
Key-value
                                      I lef Voldemort, Riak
                                   if
Document                    So rry          CouchDb

             http://nosql-database.org/ lists 122+ NoSQL databases
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
Spring Data is here to help



                                          For


                                   NoSQL databases

http://www.springsource.org/spring-data
Spring Data sub-projects
•   Relational                         •   QueryDSL
    •   JPA                            •   Big Data
    •   JDBC Extensions                    •   Hadoop
•   NoSQL                                      •    HDFS and M/R

    •   Redis                                  •    Hive

    •   Mongo                                  •    Pig

    •   HBase                                  •    Cascading

    •   Neo4j                              •   Splunk

    •   Gemfire                         •   Access

    •   Lucene                             •   REST
What you get

•   Template classes that hide the boilerplate code

•   Auto-generated (generic) repositories for some NOSQL databases

•   Java   NoSQL mapping

•   Cross Store Persistence

•   Support in Roo
Get the book!
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
Redis challenges


•   Connection management: need to get and reliably close connections

•   Data mapping: application objects       Redis binary/strings

•   Multiple client libraries with gratuitously different APIs
Spring Data for Redis

•   Low-level - RedisConnection(Factory)            •   Connection management

    •   Supports Jedis, Jredis, Rjc and Srp         •   Pluggable Java   binary conversion

    •   Insulates client code from underlying   •   Support classes:
        library
                                                    •   Collections-backed by RedisTemplate
•   High-level - RedisTemplate
                                                    •   Atomic Counters
    •   Builds on RedisConnection(Factory)
                                                •   Support for Redis pub/sub
Low-level API = RedisConnection(Factory)
Using RedisConnectionFactory
public class LowLevelRedisTest {

 @Autowired private RedisConnectionFactory redisConnectionFactory;

 @Test
 public void testLowLevel() {                                        Library independent code J
  RedisConnection con = null;
  try {
   con = redisConnectionFactory.getConnection();

     byte[] key = "foo".getBytes();                                    Ugly byte arrays L
     byte[] value = "bar".getBytes();
     con.set(key, value);

     byte[] retrievedValue = con.get(key);

     Assert.assertArrayEquals(value, retrievedValue);

  } finally {
    if (con != null) { con.close(); }
                                                                         Need to clean up L
  }
 }
Configuring RedisConnectionFactory
@Configuration
public class RedisConfiguration {

 @Value("${databaseHostName}")
 protected String databaseHostName;

 @Bean
 public RedisConnectionFactory jedisConnectionFactory() {
   JedisConnectionFactory factory = new JedisConnectionFactory();
   factory.setHostName(databaseHostName);
   factory.setPort(6379);
   factory.setUsePool(true);
   return factory;
 }

}
High-level API = RedisTemplate

•   Builds on RedisConnection(Factory)      •   Maps Redis exceptions
                                                DataAccessException
•   Analogous to JdbcTemplate
                                            •   StringRedisTemplate
•   Parameterized type
                                                •   Extends RedisTemplate<String,
    •   K - Key type
                                                    String>
    •   V – Value type
                                                •   Keys and values are Strings
•   Handles Java Key/Value   Redis byte[]
Using StringRedisTemplate
public class RedisTemplateTest {
 @Autowired private StringRedisTemplate stringRedisTemplate;            Returns KV type specific interface
 @Test
 public void testGetAndSet() {
   stringRedisTemplate.opsForValue().set("foo", "bar");
   assertEquals("bar", stringRedisTemplate.opsForValue().get("foo"));
 }
 @Test                                                                   Converts between Strings and byte[]
 public void testHashOps() {
  stringRedisTemplate.opsForHash().put("myHash", "myKey", "value");
  assertEquals("value",
    stringRedisTemplate.opsForHash().get("myHash", "myKey"));
  assertEquals(Collections.singleton("myKey"),
    stringRedisTemplate.opsForHash().keys("myHash"));
  assertEquals(Collections.singletonMap("myKey", "value"),
    stringRedisTemplate.opsForHash().entries("myHash"));
 }
Configuring StringRedisTemplate
@Configuration
public class RedisConfiguration {

 @Bean
 public RedisConnectionFactory jedisConnectionFactory() {
   …
 }

 @Bean
  public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
    StringRedisTemplate template = new StringRedisTemplate();
    template.setConnectionFactory(factory);
    return template;
  }
}
RedisTemplate: Java objects                                       binary data


•   DefaultSerializer - defaults to JdkSerializationRedisSerializer

•   KeySerializer

•   ValueSerializer

•   HashKeySerializer

•   HashValueSerializer
StringRedisTemplate uses StringRedisSerializer




•   Stores keys and values as Strings
Register serializers to override the default
                  behavior




                                Converted to JSON by RedisTemplate
Redis-backed Collections
                                         The key

@Test
public void testRedisSet() {

 Set<String> mySet =
  new DefaultRedisSet<String>("mySet", stringRedisTemplate);

 Assert.assertTrue(mySet.isEmpty());

 mySet.add("a");

 assertEquals(Collections.singleton("a"),
          stringRedisTemplate.opsForSet().members("mySet"));

}
Redis Atomic Counters
Redis Pub/Sub - Consumer
                                                                 public class MyRedisSubscriber {
@Configuration                                                     String message;
public class RedisConfiguration {
                                                                  void handleMessage(String text) {
 @Bean                                                              this.message = text;
 public MyRedisSubscriber myListener() {
   return new MyRedisSubscriber();                                }
 }                                                               }

 @Bean
 public RedisMessageListenerContainer
  redisMessageListenerContainer(
    	RedisConnectionFactory redisConnectionFactory,
    	MyRedisSubscriber myListener) {
  RedisMessageListenerContainer c =
    new RedisMessageListenerContainer();
  c.setConnectionFactory(redisConnectionFactory);
  c.addMessageListener(new MessageListenerAdapter(myListener),
                  new ChannelTopic("myChannel"));
  return c;
 }
Redis Pub/Sub - Producer
public class RedisPubSubTest {

    @Autowired private StringRedisTemplate stringRedisTemplate;

    @Autowired private MyRedisSubscriber myListener;

    @Test
    public void testPubSub() throws InterruptedException {
      …
      stringRedisTemplate.convertAndSend("myChannel", "hello");
      TimeUnit.SECONDS.sleep(4);
      Assert.assertEquals("hello", myListener.message);
    }
}
Redis caching support




                                              KVs = <prefix + K, V>
Template needs to (de)serialize K and V   Sorted set of all keys for clear()
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
MongoDB API usage patterns
•   Create and store Mongo singleton                   •   Queries

•   Externalized server host, port etc.                    •   Construct query object

•   Inserts/Updates                                        •   mongo.getDatabase(…).getCollection(…)

    •   Map application POJO       DBObject                •   Iterate through Cursor

                                                           •   Map DBObject      application POJO
    •   mongo.getDatabase(…).getCollection(…)

    •   Partial document updates

    •   Configure asynchronous vs. synchronous writes           Higher-level than JDBC but still
                                                           repetitive, …
Spring Data - MongoDB

•   MongoTemplate                      •   Map-Reduce integration

•   Query, Criteria, and Update DSLs   •   GridFS support

•   Generic repositories

•   Querydsl integration

•   Cross-store persistence

•   GeoSpatial integration
MongoTemplate
                                        MongoTemplate
                                                                       POJO ó DBObject
                        databaseName
Simplifies data access   userId
                                                                            mapping
                        Password
Translates exceptions   defaultCollectionName

                        writeConcern
                        writeResultChecking

                        save()
                        insert()
                        remove()                                                    <<interface>>
                        updateFirst()                                              MongoConvertor
                        findOne()                                write(Object, DBObject)
                        find()
                                                                read(Class, DBObject)
                        …




                                                         uses

                                         Mongo                                      MongoMapping
                                   (Java Driver class)                               Converter
Example entity
public class Restaurant {
 private String id;                  public class MenuItem {
                                      private String name;
 private String name;
                                      private double price;
 private List<MenuItem> menuItems;
                                      public MenuItem(String name, double price) {
 public Restaurant(String name) {       this.name = name;
   this.name = name;                    this.price = price;
                                      }
   …
 }                                   .....

...
}


       Spring Data uses fields and non-
              default constructors
Example data access code

@Repository
public class RestaurantRepository {

 @Autowired
 private MongoTemplate mongoTemplate;

 public void add(Restaurant restaurant) {
   mongoTemplate.save(restaurant);
 }

 public List<Restaurant> findRestaurantsByName(String restaurantName) {
    return mongoTemplate.find(
      query(where("name").is(restaurantName)),
	     Restaurant.class);
  }
A document in the restaurant collection
{
    "_id" : ObjectId("4d977f55d3fe3119c904e026"),
     "_class" : "net.chrisrichardson.mongodb.example.mongotemplate.Restaurant",
     "name" : "Ajanta"
     "menuItems" : [
	     {
	     	 "name" : "Tandoori Portobello Mushrooms",
	     	 "price" : 5.5
	     },
	     {
	     	 "name" : "Duck Curry Kerala",
	     	 "price" : 15
	     }
    ]
}
Spring MongoDB Example - Config 1
@Configuration
public class MongoExampleConfig extends AbstractMongoConfiguration {

  private @Value("#{mongoDbProperties.databaseName}")
  String mongoDbDatabase;

  private @Value("#{mongoDbProperties.host}")                                          Defines a
  String mongoDbHost;
                                                                                     MongoTemplate
  public Mongo mongo() throws Exception {
    return new Mongo(mongoDbHost);
  }

  @Override                                         <beans>
  protected String getDatabaseName() {               <context:annotation-config/>
    return mongoDbDatabase;
  }                                                 <context:component-scan base-package="net.chrisrichardson.mongodb.example"/>
...                                                 <util:properties id="mongoDbProperties" location="mongodb.properties"/>
}                         External Config
                                                    </beans>

mongodb.properties:

                 databaseName=demo1
                 host=192.168.253.150
Spring MongoDB Example - Config 2
<bean id="mongoTemplate"
   class="org.springframework.data.mongodb.core.MongoTemplate">
   <constructor-arg ref="mongoFactory"/>
</bean>

<mongo:db-factory id="mongoFactory"
  host= "#{mongoDbProperties.host}"
  dbname="#{mongoDbProperties.databaseName}" />


<util:properties
  id="mongoDbProperties"
  location="mongodb.properties"/>
Update example
@Repository
public class RestaurantRepository {
 public void addMenuItem(String restaurantId,
	 	 	         MenuItem newMenuItem) {
  mongoTemplate.updateFirst(
    query(where("_id").is(new ObjectId(restaurantId))),
    new Update().push("menuItems", newMenuItem),
    Restaurant.class);

}




          Atomic, in-place update of document
Geospatial example 1
                                                       case class FriendRecord(id : String,
                                                         name : String,
@Component
                                                         location : Point)
class MongoFriendService extends FriendService {

  @Autowired
  var mongoTemplate: MongoTemplate = _
                                                   Collection name
  @PostConstruct
  def createGeoIndex {
    val dbo = new BasicDBObject
    dbo.put("location", "2d")
    mongoTemplate.getCollection("friendRecord").ensureIndex(dbo)
  }




                                   Create geospatial 2d index
Geospatial example 2 - finding nearby
@Component
class MongoFriendService extends FriendService {



  override def findNearbyFriends(request: NearbyFriendsRequest) = {
    val location = new Point(request.longitude, request.latitude)
    val distance = new Distance(3, Metrics.MILES)
    val query = NearQuery.near(location).maxDistance(distance)

      val result = mongoTemplate.geoNear(query, classOf[FriendRecord])

      val nearby = result.getContent.map(_.getContent)
      FindNearbyFriendsResponse(nearby.map(f => FriendInfo(f.name, f.id)))
  }
Callbacks – access driver API with exception
                   translation                                        Exceptions are
                                                                        translated

@Test
public void testDbCallback() {
  Restaurant ajanta = makeAjantaRestaurant();
  restaurantRepository.add(ajanta);
  assertCollectionExists("restaurants2");
}

  private Void assertCollectionExists(final String collectionName) {
    return mongoTemplate.execute(new DbCallback<Void>(){
     @Override
     public Void doInDB(DB db) {
      Set<String> collectionNames = db.getCollectionNames();
      Assert.assertTrue("Missing from " +
               collectionNames,
	     	     collectionNames.contains(collectionName));
      return null;
     }});
  }
Defining a Mongo Generic Repository
public class Person {
  private ObjectId id;
  private String firstname;
  private String lastname;
… getters and setters
}


interface PersonRepository extends MongoRepository<Person, ObjectId> {
  List<Person> findByLastname(String lastName);
}

Person p = new Person("John", "Doe");
personRepository.save(p);

Person p2 = personRepository.findOne(p.getId());

List<Person> johnDoes = personRepository.findByLastname("Doe");
assertEquals(1, johnDoes.size());
Mongo Repository configuration
<bean>

<mongo:repositories
 base-package="net.chrisrichardson.mongodb.example.mongorepository"
   mongo-template-ref="mongoTemplate" />

</beans>




    Scans classpath looking for subtypes of MongoRepository in the base package
Richer mapping
@Document(collection=”people”)             Annotations define mapping: @Document, @Id, @Indexed,
public class Person {                      @PersistanceConstructor, @CompoundIndex, @DBRef,
                                           @GeoSpatialIndexed, @Value
 @Id
 private ObjectId id;                      Map fields instead of properties   no getters or setters
 private String firstname;
                                           required

 @Indexed
 private String lastname;                  Non-default constructor
                                           Index generation
  @PersistenceConstructor
  public Person(String firstname, String lastname) {
    this.firstname = firstname;
    this.lastname = lastname;
  }
….
}
Richer mapping configuration
@Configuration
public class MongoExampleConfig extends AbstractMongoConfiguration {
 private @Value("#{mongoDbProperties.databaseName}")
 String mongoDbDatabase;
private @Value("#{mongoDbProperties.host}")
String mongoDbHost;                                                       Defines MongoTemplate bean
@Override
public Mongo mongo() throws Exception {
  return new Mongo(mongoDbHost);
}
@Override                                                            Configures classpath scanning
public String getDatabaseName() {
  return mongoDbDatabase;
}
 @Override
  public String getMappingBasePackage() {
    return Person.class.getPackage().getName();
  }
}
Support for the QueryDSL project
            Generated from                         Type-safe
            domain model class                     composable queries



QPerson person = QPerson.person;

Predicate predicate =
	 person.homeAddress.street1.eq("1 High Street")
	 	 .and(person.firstname.eq("John"))

List<Person> people = personRepository.findAll(predicate);

assertEquals(1, people.size());
assertPersonEquals(p, people.get(0));
Cross-store/polyglot persistence
                                     Person person = new Person(…);
@Entity                              entityManager.persist(person);
public class Person {
 // In Database                      Person p2 = entityManager.find(…)
 @Id private Long id;
 private String firstname;
 private String lastname;

// In MongoDB
@RelatedDocument private Address address;

                                     { "_id" : ObjectId(”….."),
                                      "_entity_id" : NumberLong(1),
                                       "_entity_class" : "net.. Person", "_entity_field_name" : "address",
                                        "zip" : "94611", "street1" : "1 High Street", …}
Agenda

•   Why NoSQL?

•   Overview of NoSQL databases

•   Introduction to Spring Data

•   Using Spring Data for Redis

•   Using Spring Data for Mongo

•   Deploying on Cloud Foundry
Using Mongo and Redis with Cloud Foundry

•   Create a Mongo or Redis service

•   Bind the service to your application

•   Access the service

    •   Via auto-reconfiguration

    •   Using <cloud:*/> namespace
Creating a Redis Server
Deploying a Redis application
Redis bean definitions
USING THE APPLICATION
About <cloud:redis-connection-factory/>

<cloud:redis-connection-factory
          id="redisConnectionFactory"   Use when multiple
          service-name="redis1"         services are bound
/>
Deploying a Mongo application
MongoDB bean definitions
Using the Mongo Application
About <cloud:mongo-db-factory/>
                                       Use when multiple services
                                              are bound
<cloud:mongo-db-factory
          id="mongoFactory"
          service-name="mongo1"
    >
    <cloud:mongo-options
          connections-per-host="..."
          ]
          max-wait-time="..."
    />
</cloud:mongo-db-factory>
NoSQL and Caldecott
•   Caldecott let’s you tunnel to a NoSQL service

•   Use Redis CLI

    •   Explore database, adhoc operations

    •   ...

•   Use Mongo CLI etc

    •   Explore database, adhoc operations

    •   Mongo dump/restore

    •   ...
Summary

•   NoSQL databases sometimes offer a combination of:

    •   Higher scalability and performance

    •   Schema less, richer data models

•   Spring Data simplifies the development of NoSQL applications

•   Cloud Foundry supports Mongo and Redis
@crichardson chris.richardson@springsource.com
           http://plainoldobjects.com




             Questions?
Sign up for CloudFoundry.com
Cloud Foundry 启动营
在www.cloudfoundry.com注册账号并成功上传应用程序,
即可于12月8日中午后凭账号ID和应用URL到签到处换取Cloud Foundry主题卫衣一件。




84
iPhone5 等你拿
第二天大会结束前,请不要提前离      ,将填写完整的意见反馈表投到签到处的抽奖箱内,
即可参与“iPhone5”抽奖活动。




85
Birds of a Feather 专家面对面
所有讲师都会在课程结束后,到紫兰厅与来宾讨论课程上的问题




86

Weitere ähnliche Inhalte

Was ist angesagt?

Polyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherPolyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherJohn Wood
 
2011 03-31 Riak Stockholm Meetup
2011 03-31 Riak Stockholm Meetup2011 03-31 Riak Stockholm Meetup
2011 03-31 Riak Stockholm MeetupMårten Gustafson
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Javasunnygleason
 
PayPal Big Data and MySQL Cluster
PayPal Big Data and MySQL ClusterPayPal Big Data and MySQL Cluster
PayPal Big Data and MySQL ClusterMat Keep
 
keyvi the key value index @ Cliqz
keyvi the key value index @ Cliqzkeyvi the key value index @ Cliqz
keyvi the key value index @ CliqzHendrik Muhs
 
Growing in the Wild. The story by CUBRID Database Developers.
Growing in the Wild. The story by CUBRID Database Developers.Growing in the Wild. The story by CUBRID Database Developers.
Growing in the Wild. The story by CUBRID Database Developers.CUBRID
 
Conference tutorial: MySQL Cluster as NoSQL
Conference tutorial: MySQL Cluster as NoSQLConference tutorial: MySQL Cluster as NoSQL
Conference tutorial: MySQL Cluster as NoSQLSeveralnines
 
Mongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMitch Pirtle
 
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDBBenchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDBAthiq Ahamed
 
RedisConf17 - Using Redis and RediSearch Module
RedisConf17 - Using Redis and RediSearch ModuleRedisConf17 - Using Redis and RediSearch Module
RedisConf17 - Using Redis and RediSearch ModuleRedis Labs
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)Steve Min
 
MySQL Cluster NoSQL Memcached API
MySQL Cluster NoSQL Memcached APIMySQL Cluster NoSQL Memcached API
MySQL Cluster NoSQL Memcached APIMat Keep
 
NoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesNoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesRonen Botzer
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
Postgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can EatPostgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can EatEDB
 
Yes sql08 inmemorydb
Yes sql08 inmemorydbYes sql08 inmemorydb
Yes sql08 inmemorydbDaniel Austin
 

Was ist angesagt? (20)

Methods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarkingMethods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarking
 
Polyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherPolyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great Together
 
2011 03-31 Riak Stockholm Meetup
2011 03-31 Riak Stockholm Meetup2011 03-31 Riak Stockholm Meetup
2011 03-31 Riak Stockholm Meetup
 
NoSQL @ Qbranch -2010-04-15
NoSQL @ Qbranch -2010-04-15NoSQL @ Qbranch -2010-04-15
NoSQL @ Qbranch -2010-04-15
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Java
 
Wmware NoSQL
Wmware NoSQLWmware NoSQL
Wmware NoSQL
 
PayPal Big Data and MySQL Cluster
PayPal Big Data and MySQL ClusterPayPal Big Data and MySQL Cluster
PayPal Big Data and MySQL Cluster
 
keyvi the key value index @ Cliqz
keyvi the key value index @ Cliqzkeyvi the key value index @ Cliqz
keyvi the key value index @ Cliqz
 
Growing in the Wild. The story by CUBRID Database Developers.
Growing in the Wild. The story by CUBRID Database Developers.Growing in the Wild. The story by CUBRID Database Developers.
Growing in the Wild. The story by CUBRID Database Developers.
 
Conference tutorial: MySQL Cluster as NoSQL
Conference tutorial: MySQL Cluster as NoSQLConference tutorial: MySQL Cluster as NoSQL
Conference tutorial: MySQL Cluster as NoSQL
 
Mongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case Study
 
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDBBenchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
 
RedisConf17 - Using Redis and RediSearch Module
RedisConf17 - Using Redis and RediSearch ModuleRedisConf17 - Using Redis and RediSearch Module
RedisConf17 - Using Redis and RediSearch Module
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)
 
MySQL Cluster NoSQL Memcached API
MySQL Cluster NoSQL Memcached APIMySQL Cluster NoSQL Memcached API
MySQL Cluster NoSQL Memcached API
 
NoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesNoSQL in Real-time Architectures
NoSQL in Real-time Architectures
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
Postgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can EatPostgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can Eat
 
Yes sql08 inmemorydb
Yes sql08 inmemorydbYes sql08 inmemorydb
Yes sql08 inmemorydb
 
NOSQL Overview
NOSQL OverviewNOSQL Overview
NOSQL Overview
 

Andere mochten auch

Developing applications with Cloud Services (Devnexus 2013)
Developing applications with Cloud Services (Devnexus 2013)Developing applications with Cloud Services (Devnexus 2013)
Developing applications with Cloud Services (Devnexus 2013)Chris Richardson
 
Polygot persistence for Java Developers - August 2011 / @Oakjug
Polygot persistence for Java Developers - August 2011 / @OakjugPolygot persistence for Java Developers - August 2011 / @Oakjug
Polygot persistence for Java Developers - August 2011 / @OakjugChris Richardson
 
Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Chris Richardson
 
Developing polyglot persistence applications (devnexus 2013)
Developing polyglot persistence applications (devnexus 2013)Developing polyglot persistence applications (devnexus 2013)
Developing polyglot persistence applications (devnexus 2013)Chris Richardson
 
Developing applications with Cloud Services #javaone 2012
Developing applications with Cloud Services  #javaone 2012Developing applications with Cloud Services  #javaone 2012
Developing applications with Cloud Services #javaone 2012Chris Richardson
 
Decomposing applications for scalability and deployability - svcc sv_code_ca...
Decomposing applications for scalability and deployability  - svcc sv_code_ca...Decomposing applications for scalability and deployability  - svcc sv_code_ca...
Decomposing applications for scalability and deployability - svcc sv_code_ca...Chris Richardson
 
Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Chris Richardson
 
Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Chris Richardson
 
Developing polyglot persistence applications (gluecon 2013)
Developing polyglot persistence applications (gluecon 2013)Developing polyglot persistence applications (gluecon 2013)
Developing polyglot persistence applications (gluecon 2013)Chris Richardson
 
NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)Chris Richardson
 
Microservices pattern language (microxchg microxchg2016)
Microservices pattern language (microxchg microxchg2016)Microservices pattern language (microxchg microxchg2016)
Microservices pattern language (microxchg microxchg2016)Chris Richardson
 
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Chris Richardson
 
Nosql databases for the .net developer
Nosql databases for the .net developerNosql databases for the .net developer
Nosql databases for the .net developerJesus Rodriguez
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraFolio3 Software
 
A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014Anuj Sahni
 
Big Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI ProsBig Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI ProsAndrew Brust
 
An Intro to NoSQL Databases
An Intro to NoSQL DatabasesAn Intro to NoSQL Databases
An Intro to NoSQL DatabasesRajith Pemabandu
 

Andere mochten auch (20)

Developing applications with Cloud Services (Devnexus 2013)
Developing applications with Cloud Services (Devnexus 2013)Developing applications with Cloud Services (Devnexus 2013)
Developing applications with Cloud Services (Devnexus 2013)
 
Polygot persistence for Java Developers - August 2011 / @Oakjug
Polygot persistence for Java Developers - August 2011 / @OakjugPolygot persistence for Java Developers - August 2011 / @Oakjug
Polygot persistence for Java Developers - August 2011 / @Oakjug
 
Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...
 
Developing polyglot persistence applications (devnexus 2013)
Developing polyglot persistence applications (devnexus 2013)Developing polyglot persistence applications (devnexus 2013)
Developing polyglot persistence applications (devnexus 2013)
 
Developing applications with Cloud Services #javaone 2012
Developing applications with Cloud Services  #javaone 2012Developing applications with Cloud Services  #javaone 2012
Developing applications with Cloud Services #javaone 2012
 
Decomposing applications for scalability and deployability - svcc sv_code_ca...
Decomposing applications for scalability and deployability  - svcc sv_code_ca...Decomposing applications for scalability and deployability  - svcc sv_code_ca...
Decomposing applications for scalability and deployability - svcc sv_code_ca...
 
Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)
 
Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)
 
Developing polyglot persistence applications (gluecon 2013)
Developing polyglot persistence applications (gluecon 2013)Developing polyglot persistence applications (gluecon 2013)
Developing polyglot persistence applications (gluecon 2013)
 
NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)
 
Microservices pattern language (microxchg microxchg2016)
Microservices pattern language (microxchg microxchg2016)Microservices pattern language (microxchg microxchg2016)
Microservices pattern language (microxchg microxchg2016)
 
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
 
Taming NoSQL with Spring Data
Taming NoSQL with Spring DataTaming NoSQL with Spring Data
Taming NoSQL with Spring Data
 
NoSql Databases
NoSql DatabasesNoSql Databases
NoSql Databases
 
Nosql databases for the .net developer
Nosql databases for the .net developerNosql databases for the .net developer
Nosql databases for the .net developer
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
 
A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014
 
Big Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI ProsBig Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI Pros
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
An Intro to NoSQL Databases
An Intro to NoSQL DatabasesAn Intro to NoSQL Databases
An Intro to NoSQL Databases
 

Ähnlich wie Using Spring with NoSQL databases (SpringOne China 2012)

MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FSMongoDB
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataRoger Xia
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDBMongoDB
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewAntonio Pintus
 
Scaling MongoDB
Scaling MongoDBScaling MongoDB
Scaling MongoDBMongoDB
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsSteven Francia
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at ScaleMongoDB
 
Meetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebServiceMeetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebServiceMinsk MongoDB User Group
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015Himanshu Desai
 
An Introduction to Big Data, NoSQL and MongoDB
An Introduction to Big Data, NoSQL and MongoDBAn Introduction to Big Data, NoSQL and MongoDB
An Introduction to Big Data, NoSQL and MongoDBWilliam LaForest
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQLYan Cui
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
NoSQL in the context of Social Web
NoSQL in the context of Social WebNoSQL in the context of Social Web
NoSQL in the context of Social WebBogdan Gaza
 

Ähnlich wie Using Spring with NoSQL databases (SpringOne China 2012) (20)

KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
 
Drop acid
Drop acidDrop acid
Drop acid
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
 
Scaling MongoDB
Scaling MongoDBScaling MongoDB
Scaling MongoDB
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at Scale
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Meetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebServiceMeetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebService
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
An Introduction to Big Data, NoSQL and MongoDB
An Introduction to Big Data, NoSQL and MongoDBAn Introduction to Big Data, NoSQL and MongoDB
An Introduction to Big Data, NoSQL and MongoDB
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
CouchDB introduction
CouchDB introductionCouchDB introduction
CouchDB introduction
 
NoSQL in the context of Social Web
NoSQL in the context of Social WebNoSQL in the context of Social Web
NoSQL in the context of Social Web
 
Introduction to Apache Drill
Introduction to Apache DrillIntroduction to Apache Drill
Introduction to Apache Drill
 

Mehr von Chris Richardson

The microservice architecture: what, why, when and how?
The microservice architecture: what, why, when and how?The microservice architecture: what, why, when and how?
The microservice architecture: what, why, when and how?Chris Richardson
 
More the merrier: a microservices anti-pattern
More the merrier: a microservices anti-patternMore the merrier: a microservices anti-pattern
More the merrier: a microservices anti-patternChris Richardson
 
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...Chris Richardson
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Chris Richardson
 
Dark energy, dark matter and microservice architecture collaboration patterns
Dark energy, dark matter and microservice architecture collaboration patternsDark energy, dark matter and microservice architecture collaboration patterns
Dark energy, dark matter and microservice architecture collaboration patternsChris Richardson
 
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
Scenarios_and_Architecture_SkillsMatter_April_2022.pdfScenarios_and_Architecture_SkillsMatter_April_2022.pdf
Scenarios_and_Architecture_SkillsMatter_April_2022.pdfChris Richardson
 
Using patterns and pattern languages to make better architectural decisions
Using patterns and pattern languages to make better architectural decisions Using patterns and pattern languages to make better architectural decisions
Using patterns and pattern languages to make better architectural decisions Chris Richardson
 
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...Chris Richardson
 
Events to the rescue: solving distributed data problems in a microservice arc...
Events to the rescue: solving distributed data problems in a microservice arc...Events to the rescue: solving distributed data problems in a microservice arc...
Events to the rescue: solving distributed data problems in a microservice arc...Chris Richardson
 
A pattern language for microservices - June 2021
A pattern language for microservices - June 2021 A pattern language for microservices - June 2021
A pattern language for microservices - June 2021 Chris Richardson
 
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice ArchitectureQConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice ArchitectureChris Richardson
 
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...Chris Richardson
 
Designing loosely coupled services
Designing loosely coupled servicesDesigning loosely coupled services
Designing loosely coupled servicesChris Richardson
 
Microservices - an architecture that enables DevOps (T Systems DevOps day)
Microservices - an architecture that enables DevOps (T Systems DevOps day)Microservices - an architecture that enables DevOps (T Systems DevOps day)
Microservices - an architecture that enables DevOps (T Systems DevOps day)Chris Richardson
 
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...Chris Richardson
 
Decompose your monolith: Six principles for refactoring a monolith to microse...
Decompose your monolith: Six principles for refactoring a monolith to microse...Decompose your monolith: Six principles for refactoring a monolith to microse...
Decompose your monolith: Six principles for refactoring a monolith to microse...Chris Richardson
 
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...Chris Richardson
 
Overview of the Eventuate Tram Customers and Orders application
Overview of the Eventuate Tram Customers and Orders applicationOverview of the Eventuate Tram Customers and Orders application
Overview of the Eventuate Tram Customers and Orders applicationChris Richardson
 
An overview of the Eventuate Platform
An overview of the Eventuate PlatformAn overview of the Eventuate Platform
An overview of the Eventuate PlatformChris Richardson
 
#DevNexus202 Decompose your monolith
#DevNexus202 Decompose your monolith#DevNexus202 Decompose your monolith
#DevNexus202 Decompose your monolithChris Richardson
 

Mehr von Chris Richardson (20)

The microservice architecture: what, why, when and how?
The microservice architecture: what, why, when and how?The microservice architecture: what, why, when and how?
The microservice architecture: what, why, when and how?
 
More the merrier: a microservices anti-pattern
More the merrier: a microservices anti-patternMore the merrier: a microservices anti-pattern
More the merrier: a microservices anti-pattern
 
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!
 
Dark energy, dark matter and microservice architecture collaboration patterns
Dark energy, dark matter and microservice architecture collaboration patternsDark energy, dark matter and microservice architecture collaboration patterns
Dark energy, dark matter and microservice architecture collaboration patterns
 
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
Scenarios_and_Architecture_SkillsMatter_April_2022.pdfScenarios_and_Architecture_SkillsMatter_April_2022.pdf
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
 
Using patterns and pattern languages to make better architectural decisions
Using patterns and pattern languages to make better architectural decisions Using patterns and pattern languages to make better architectural decisions
Using patterns and pattern languages to make better architectural decisions
 
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
 
Events to the rescue: solving distributed data problems in a microservice arc...
Events to the rescue: solving distributed data problems in a microservice arc...Events to the rescue: solving distributed data problems in a microservice arc...
Events to the rescue: solving distributed data problems in a microservice arc...
 
A pattern language for microservices - June 2021
A pattern language for microservices - June 2021 A pattern language for microservices - June 2021
A pattern language for microservices - June 2021
 
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice ArchitectureQConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
 
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
 
Designing loosely coupled services
Designing loosely coupled servicesDesigning loosely coupled services
Designing loosely coupled services
 
Microservices - an architecture that enables DevOps (T Systems DevOps day)
Microservices - an architecture that enables DevOps (T Systems DevOps day)Microservices - an architecture that enables DevOps (T Systems DevOps day)
Microservices - an architecture that enables DevOps (T Systems DevOps day)
 
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
 
Decompose your monolith: Six principles for refactoring a monolith to microse...
Decompose your monolith: Six principles for refactoring a monolith to microse...Decompose your monolith: Six principles for refactoring a monolith to microse...
Decompose your monolith: Six principles for refactoring a monolith to microse...
 
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
 
Overview of the Eventuate Tram Customers and Orders application
Overview of the Eventuate Tram Customers and Orders applicationOverview of the Eventuate Tram Customers and Orders application
Overview of the Eventuate Tram Customers and Orders application
 
An overview of the Eventuate Platform
An overview of the Eventuate PlatformAn overview of the Eventuate Platform
An overview of the Eventuate Platform
 
#DevNexus202 Decompose your monolith
#DevNexus202 Decompose your monolith#DevNexus202 Decompose your monolith
#DevNexus202 Decompose your monolith
 

Kürzlich hochgeladen

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 

Kürzlich hochgeladen (20)

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 

Using Spring with NoSQL databases (SpringOne China 2012)

  • 1. Using Spring with NoSQL databases Chris Richardson, Author of POJOs in Action, Founder of the original CloudFoundry.com @crichardson chris.richardson@springsource.com http://plainoldobjects.com/
  • 2. Presentation goal NoSQL databases: what, why and how How Spring Data simplifies the development of NoSQL applications
  • 8. vmc push About-Chris Developer Advocate Signup at http://cloudfoundry.com
  • 9. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 10. Relational databases are great... • SQL • Well supported • High-level • JDBC • Sorting • Hibernate/JPA • Aggregation • Spring • ACID semantics • Well understood • Developers • Operators
  • 11. ... but they have limitations • Object/relational impedance mismatch • Complicated to map rich domain model to relational schema • Difficult to handle semi-structured data, e.g. varying attributes • Schema changes • Extremely difficult/impossible to scale • Poor performance for some use cases
  • 12. Solution: Spend Money OR http://upload.wikimedia.org/wikipedia/commons/e/e5/Rising_Sun_Yacht.JPG • Hire more DevOps • Use application-level sharding • Build your own middleware • … http://www.trekbikes.com/us/en/bikes/road/race_performance/madone_5_series/madone_5_2/#
  • 13. Solution: Use NoSQL Benefits • Higher performance • Higher scalability • Richer data-model • Schema-less Drawbacks • Limited transactions • Relaxed consistency • Unconstrained data
  • 15. But don’t get too excited
  • 16. Solution: Use NewSQL • Relational databases with SQL and ACID transactions AND • New and improved architecture - designed for modern hardware • Radically better scalability and performance • NewSQL vendors: Gemfire/SQLFire, VoltDB, ...
  • 17. Future = multi-paradigm data storage for enterprise applications IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg
  • 18. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 19. Redis • Advanced key-value store K1 V1 • Written in C K2 V2 • Very fast, e.g. 100K reqs/sec • Optional persistence ... ... • Transactions with optimistic locking • Master-slave replication • Sharding using client-side consistent hashing
  • 20. Using Redis (via CLI) Datatypes: redis 127.0.0.1:6379> set foo 1 OK •Strings redis 127.0.0.1:6379> get foo •Hashes "1" •Maps redis 127.0.0.1:6379> sadd myset a •Lists (integer) 1 •Sets redis 127.0.0.1:6379> sadd myset b (integer) 1 •Sorted sets redis 127.0.0.1:6379> smembers myset 1) "a" 2) "b" redis 127.0.0.1:6379> srem myset a (integer) 1 redis 127.0.0.1:6379> smembers myset 1) "b"
  • 21. Redis use cases • Replacement for Memcached • Handling tasks that overload an RDBMS • Session state • Hit counts - INCR • Cache of data retrieved from system of • Most recent N items - LPUSH and LTRIM record (SOR) • Randomly selecting an item – • Replica of SOR for queries needing high- SRANDMEMBER performance • Queuing – Lists with LPOP, RPUSH, …. • High score tables – Sorted sets and ZINCRBY • …
  • 22. MongoDB • Document-oriented database • Geospatial queries • JSON-style documents: objects, lists, • Grid FS provides file storage primitives • Very fast, asynchronous writes • Schema-less • Highly scalable and available • Transaction = update of a single document • Rich query language for dynamic queries
  • 23. Data model = Binary JSON documents Server Database: Food To Go Collection: Restaurants { "name" : "TGI Fridays", "type" : ”American", "serviceArea" : [ "94619", "94618" ], Sequence of "openingHours" : [ bytes on disk { è fast i/o "dayOfWeek" : "Wednesday", "open" : 1730, "close" : 2230 } ], "_id" : ObjectId("4bddc2f49d1505567c6220a0") }
  • 24. MongoDB CLI > r = {name: 'Ajanta'} > db.restaurants.save(r) > r { "_id" : ObjectId("4e555dd9646e338dca11710c"), "name" : "Ajanta" } > r = db.restaurants.findOne({name:"Ajanta"}) { "_id" : ObjectId("4e555dd9646e338dca11710c"), "name" : "Ajanta" } > r.type= "Indian” > db.restaurants.save(r) > db.restaurants.update({name:"Ajanta"}, {$set: {name:"Ajanta Restaurant"}, $push: { menuItems: {name: "Chicken Vindaloo"}}}) > db.restaurants.find() { "_id" : ObjectId("4e555dd9646e338dca11710c"), "menuItems" : [ { "name" : "Chicken Vindaloo" } ], "name" : "Ajanta Restaurant", "type" : "Indian" } > db.restaurants.remove(r.id)
  • 25. MongoDB query by example { serviceArea:"94619", Find a restaurant that openingHours: { serves the 94619 zip $elemMatch : { code and is open at 6pm "dayOfWeek" : "Monday", "open": {$lte: 1800}, on a Monday "close": {$gte: 1800} } } } DBCursor cursor = collection.find(qbeObject); while (cursor.hasNext()) { DBObject o = cursor.next(); … }
  • 26. Scaling MongoDB Shard 1 Shard 2 Mongod Mongod (replica) (replica) Mongod Mongod Mongod Mongod (master) (replica) (master) (replica) Config Server Mongos mongod Mongos mongod Client mongod
  • 27. MongoDB use cases • Use cases • Who is using it? • High volume writes • Shutterfly, Foursquare • Complex data • Bit.ly Intuit • Semi-structured data • SourceForge, NY Times • GILT Groupe, Evite, • SugarCRM
  • 28. Other NoSQL databases Type Examples Extensible columns/Column-oriented Hbase e SimpleDB, DynamoDB r it avo Cassandra r f you Graph Neo4j t t ou Key-value I lef Voldemort, Riak if Document So rry CouchDb http://nosql-database.org/ lists 122+ NoSQL databases
  • 29. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 30. Spring Data is here to help For NoSQL databases http://www.springsource.org/spring-data
  • 31. Spring Data sub-projects • Relational • QueryDSL • JPA • Big Data • JDBC Extensions • Hadoop • NoSQL • HDFS and M/R • Redis • Hive • Mongo • Pig • HBase • Cascading • Neo4j • Splunk • Gemfire • Access • Lucene • REST
  • 32. What you get • Template classes that hide the boilerplate code • Auto-generated (generic) repositories for some NOSQL databases • Java NoSQL mapping • Cross Store Persistence • Support in Roo
  • 34. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 35. Redis challenges • Connection management: need to get and reliably close connections • Data mapping: application objects Redis binary/strings • Multiple client libraries with gratuitously different APIs
  • 36. Spring Data for Redis • Low-level - RedisConnection(Factory) • Connection management • Supports Jedis, Jredis, Rjc and Srp • Pluggable Java binary conversion • Insulates client code from underlying • Support classes: library • Collections-backed by RedisTemplate • High-level - RedisTemplate • Atomic Counters • Builds on RedisConnection(Factory) • Support for Redis pub/sub
  • 37. Low-level API = RedisConnection(Factory)
  • 38. Using RedisConnectionFactory public class LowLevelRedisTest { @Autowired private RedisConnectionFactory redisConnectionFactory; @Test public void testLowLevel() { Library independent code J RedisConnection con = null; try { con = redisConnectionFactory.getConnection(); byte[] key = "foo".getBytes(); Ugly byte arrays L byte[] value = "bar".getBytes(); con.set(key, value); byte[] retrievedValue = con.get(key); Assert.assertArrayEquals(value, retrievedValue); } finally { if (con != null) { con.close(); } Need to clean up L } }
  • 39. Configuring RedisConnectionFactory @Configuration public class RedisConfiguration { @Value("${databaseHostName}") protected String databaseHostName; @Bean public RedisConnectionFactory jedisConnectionFactory() { JedisConnectionFactory factory = new JedisConnectionFactory(); factory.setHostName(databaseHostName); factory.setPort(6379); factory.setUsePool(true); return factory; } }
  • 40. High-level API = RedisTemplate • Builds on RedisConnection(Factory) • Maps Redis exceptions DataAccessException • Analogous to JdbcTemplate • StringRedisTemplate • Parameterized type • Extends RedisTemplate<String, • K - Key type String> • V – Value type • Keys and values are Strings • Handles Java Key/Value Redis byte[]
  • 41. Using StringRedisTemplate public class RedisTemplateTest { @Autowired private StringRedisTemplate stringRedisTemplate; Returns KV type specific interface @Test public void testGetAndSet() { stringRedisTemplate.opsForValue().set("foo", "bar"); assertEquals("bar", stringRedisTemplate.opsForValue().get("foo")); } @Test Converts between Strings and byte[] public void testHashOps() { stringRedisTemplate.opsForHash().put("myHash", "myKey", "value"); assertEquals("value", stringRedisTemplate.opsForHash().get("myHash", "myKey")); assertEquals(Collections.singleton("myKey"), stringRedisTemplate.opsForHash().keys("myHash")); assertEquals(Collections.singletonMap("myKey", "value"), stringRedisTemplate.opsForHash().entries("myHash")); }
  • 42. Configuring StringRedisTemplate @Configuration public class RedisConfiguration { @Bean public RedisConnectionFactory jedisConnectionFactory() { … } @Bean public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(); template.setConnectionFactory(factory); return template; } }
  • 43. RedisTemplate: Java objects binary data • DefaultSerializer - defaults to JdkSerializationRedisSerializer • KeySerializer • ValueSerializer • HashKeySerializer • HashValueSerializer
  • 44. StringRedisTemplate uses StringRedisSerializer • Stores keys and values as Strings
  • 45. Register serializers to override the default behavior Converted to JSON by RedisTemplate
  • 46. Redis-backed Collections The key @Test public void testRedisSet() { Set<String> mySet = new DefaultRedisSet<String>("mySet", stringRedisTemplate); Assert.assertTrue(mySet.isEmpty()); mySet.add("a"); assertEquals(Collections.singleton("a"), stringRedisTemplate.opsForSet().members("mySet")); }
  • 48. Redis Pub/Sub - Consumer public class MyRedisSubscriber { @Configuration String message; public class RedisConfiguration { void handleMessage(String text) { @Bean this.message = text; public MyRedisSubscriber myListener() { return new MyRedisSubscriber(); } } } @Bean public RedisMessageListenerContainer redisMessageListenerContainer( RedisConnectionFactory redisConnectionFactory, MyRedisSubscriber myListener) { RedisMessageListenerContainer c = new RedisMessageListenerContainer(); c.setConnectionFactory(redisConnectionFactory); c.addMessageListener(new MessageListenerAdapter(myListener), new ChannelTopic("myChannel")); return c; }
  • 49. Redis Pub/Sub - Producer public class RedisPubSubTest { @Autowired private StringRedisTemplate stringRedisTemplate; @Autowired private MyRedisSubscriber myListener; @Test public void testPubSub() throws InterruptedException { … stringRedisTemplate.convertAndSend("myChannel", "hello"); TimeUnit.SECONDS.sleep(4); Assert.assertEquals("hello", myListener.message); } }
  • 50. Redis caching support KVs = <prefix + K, V> Template needs to (de)serialize K and V Sorted set of all keys for clear()
  • 51. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 52. MongoDB API usage patterns • Create and store Mongo singleton • Queries • Externalized server host, port etc. • Construct query object • Inserts/Updates • mongo.getDatabase(…).getCollection(…) • Map application POJO DBObject • Iterate through Cursor • Map DBObject application POJO • mongo.getDatabase(…).getCollection(…) • Partial document updates • Configure asynchronous vs. synchronous writes Higher-level than JDBC but still repetitive, …
  • 53. Spring Data - MongoDB • MongoTemplate • Map-Reduce integration • Query, Criteria, and Update DSLs • GridFS support • Generic repositories • Querydsl integration • Cross-store persistence • GeoSpatial integration
  • 54. MongoTemplate MongoTemplate POJO ó DBObject databaseName Simplifies data access userId mapping Password Translates exceptions defaultCollectionName writeConcern writeResultChecking save() insert() remove() <<interface>> updateFirst() MongoConvertor findOne() write(Object, DBObject) find() read(Class, DBObject) … uses Mongo MongoMapping (Java Driver class) Converter
  • 55. Example entity public class Restaurant { private String id; public class MenuItem { private String name; private String name; private double price; private List<MenuItem> menuItems; public MenuItem(String name, double price) { public Restaurant(String name) { this.name = name; this.name = name; this.price = price; } … } ..... ... } Spring Data uses fields and non- default constructors
  • 56. Example data access code @Repository public class RestaurantRepository { @Autowired private MongoTemplate mongoTemplate; public void add(Restaurant restaurant) { mongoTemplate.save(restaurant); } public List<Restaurant> findRestaurantsByName(String restaurantName) { return mongoTemplate.find( query(where("name").is(restaurantName)), Restaurant.class); }
  • 57. A document in the restaurant collection { "_id" : ObjectId("4d977f55d3fe3119c904e026"), "_class" : "net.chrisrichardson.mongodb.example.mongotemplate.Restaurant", "name" : "Ajanta" "menuItems" : [ { "name" : "Tandoori Portobello Mushrooms", "price" : 5.5 }, { "name" : "Duck Curry Kerala", "price" : 15 } ] }
  • 58. Spring MongoDB Example - Config 1 @Configuration public class MongoExampleConfig extends AbstractMongoConfiguration { private @Value("#{mongoDbProperties.databaseName}") String mongoDbDatabase; private @Value("#{mongoDbProperties.host}") Defines a String mongoDbHost; MongoTemplate public Mongo mongo() throws Exception { return new Mongo(mongoDbHost); } @Override <beans> protected String getDatabaseName() { <context:annotation-config/> return mongoDbDatabase; } <context:component-scan base-package="net.chrisrichardson.mongodb.example"/> ... <util:properties id="mongoDbProperties" location="mongodb.properties"/> } External Config </beans> mongodb.properties: databaseName=demo1 host=192.168.253.150
  • 59. Spring MongoDB Example - Config 2 <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongoFactory"/> </bean> <mongo:db-factory id="mongoFactory" host= "#{mongoDbProperties.host}" dbname="#{mongoDbProperties.databaseName}" /> <util:properties id="mongoDbProperties" location="mongodb.properties"/>
  • 60. Update example @Repository public class RestaurantRepository { public void addMenuItem(String restaurantId, MenuItem newMenuItem) { mongoTemplate.updateFirst( query(where("_id").is(new ObjectId(restaurantId))), new Update().push("menuItems", newMenuItem), Restaurant.class); } Atomic, in-place update of document
  • 61. Geospatial example 1 case class FriendRecord(id : String, name : String, @Component location : Point) class MongoFriendService extends FriendService { @Autowired var mongoTemplate: MongoTemplate = _ Collection name @PostConstruct def createGeoIndex { val dbo = new BasicDBObject dbo.put("location", "2d") mongoTemplate.getCollection("friendRecord").ensureIndex(dbo) } Create geospatial 2d index
  • 62. Geospatial example 2 - finding nearby @Component class MongoFriendService extends FriendService { override def findNearbyFriends(request: NearbyFriendsRequest) = { val location = new Point(request.longitude, request.latitude) val distance = new Distance(3, Metrics.MILES) val query = NearQuery.near(location).maxDistance(distance) val result = mongoTemplate.geoNear(query, classOf[FriendRecord]) val nearby = result.getContent.map(_.getContent) FindNearbyFriendsResponse(nearby.map(f => FriendInfo(f.name, f.id))) }
  • 63. Callbacks – access driver API with exception translation Exceptions are translated @Test public void testDbCallback() { Restaurant ajanta = makeAjantaRestaurant(); restaurantRepository.add(ajanta); assertCollectionExists("restaurants2"); } private Void assertCollectionExists(final String collectionName) { return mongoTemplate.execute(new DbCallback<Void>(){ @Override public Void doInDB(DB db) { Set<String> collectionNames = db.getCollectionNames(); Assert.assertTrue("Missing from " + collectionNames, collectionNames.contains(collectionName)); return null; }}); }
  • 64. Defining a Mongo Generic Repository public class Person { private ObjectId id; private String firstname; private String lastname; … getters and setters } interface PersonRepository extends MongoRepository<Person, ObjectId> { List<Person> findByLastname(String lastName); } Person p = new Person("John", "Doe"); personRepository.save(p); Person p2 = personRepository.findOne(p.getId()); List<Person> johnDoes = personRepository.findByLastname("Doe"); assertEquals(1, johnDoes.size());
  • 65. Mongo Repository configuration <bean> <mongo:repositories base-package="net.chrisrichardson.mongodb.example.mongorepository" mongo-template-ref="mongoTemplate" /> </beans> Scans classpath looking for subtypes of MongoRepository in the base package
  • 66. Richer mapping @Document(collection=”people”) Annotations define mapping: @Document, @Id, @Indexed, public class Person { @PersistanceConstructor, @CompoundIndex, @DBRef, @GeoSpatialIndexed, @Value @Id private ObjectId id; Map fields instead of properties no getters or setters private String firstname; required @Indexed private String lastname; Non-default constructor Index generation @PersistenceConstructor public Person(String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; } …. }
  • 67. Richer mapping configuration @Configuration public class MongoExampleConfig extends AbstractMongoConfiguration { private @Value("#{mongoDbProperties.databaseName}") String mongoDbDatabase; private @Value("#{mongoDbProperties.host}") String mongoDbHost; Defines MongoTemplate bean @Override public Mongo mongo() throws Exception { return new Mongo(mongoDbHost); } @Override Configures classpath scanning public String getDatabaseName() { return mongoDbDatabase; } @Override public String getMappingBasePackage() { return Person.class.getPackage().getName(); } }
  • 68. Support for the QueryDSL project Generated from Type-safe domain model class composable queries QPerson person = QPerson.person; Predicate predicate = person.homeAddress.street1.eq("1 High Street") .and(person.firstname.eq("John")) List<Person> people = personRepository.findAll(predicate); assertEquals(1, people.size()); assertPersonEquals(p, people.get(0));
  • 69. Cross-store/polyglot persistence Person person = new Person(…); @Entity entityManager.persist(person); public class Person { // In Database Person p2 = entityManager.find(…) @Id private Long id; private String firstname; private String lastname; // In MongoDB @RelatedDocument private Address address; { "_id" : ObjectId(”….."), "_entity_id" : NumberLong(1), "_entity_class" : "net.. Person", "_entity_field_name" : "address", "zip" : "94611", "street1" : "1 High Street", …}
  • 70. Agenda • Why NoSQL? • Overview of NoSQL databases • Introduction to Spring Data • Using Spring Data for Redis • Using Spring Data for Mongo • Deploying on Cloud Foundry
  • 71. Using Mongo and Redis with Cloud Foundry • Create a Mongo or Redis service • Bind the service to your application • Access the service • Via auto-reconfiguration • Using <cloud:*/> namespace
  • 73. Deploying a Redis application
  • 76. About <cloud:redis-connection-factory/> <cloud:redis-connection-factory id="redisConnectionFactory" Use when multiple service-name="redis1" services are bound />
  • 77. Deploying a Mongo application
  • 79. Using the Mongo Application
  • 80. About <cloud:mongo-db-factory/> Use when multiple services are bound <cloud:mongo-db-factory id="mongoFactory" service-name="mongo1" > <cloud:mongo-options connections-per-host="..." ] max-wait-time="..." /> </cloud:mongo-db-factory>
  • 81. NoSQL and Caldecott • Caldecott let’s you tunnel to a NoSQL service • Use Redis CLI • Explore database, adhoc operations • ... • Use Mongo CLI etc • Explore database, adhoc operations • Mongo dump/restore • ...
  • 82. Summary • NoSQL databases sometimes offer a combination of: • Higher scalability and performance • Schema less, richer data models • Spring Data simplifies the development of NoSQL applications • Cloud Foundry supports Mongo and Redis
  • 83. @crichardson chris.richardson@springsource.com http://plainoldobjects.com Questions? Sign up for CloudFoundry.com
  • 85. iPhone5 等你拿 第二天大会结束前,请不要提前离 ,将填写完整的意见反馈表投到签到处的抽奖箱内, 即可参与“iPhone5”抽奖活动。 85
  • 86. Birds of a Feather 专家面对面 所有讲师都会在课程结束后,到紫兰厅与来宾讨论课程上的问题 86