Cassandra data access

3,057 views
2,891 views

Published on

from Netherlands Cassandra Users Meet Up 28 May 2013

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,057
On SlideShare
0
From Embeds
0
Number of Embeds
1,807
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cassandra data access

  1. 1. Cassandra Data Access in Java
  2. 2. eBuddy use of Cassandra
  3. 3. XMS
  4. 4. ● User Data Service● User Discovery Service● Persistent Session Store● Message History● Location-based DiscoveryCassandra ineBuddy Messaging Platform
  5. 5. ● Current size of data● 1,4 TiB total (replication of 3x); 467 GiB actual data● 12 million sessions (11 million users plus groups)● Almost a billion rows in one column family(inverse social graph)Some Statistics
  6. 6. Data Access - Overview
  7. 7. Design Objectives● Data Source Agnostic● Testable● Thread Safe● Strong Typing● Supports “transactions”, i.e. units of work in batch● Efficient Mapping to Application Domain Model● Follows Familiar Patterns (e.g. Spring JDBC Template)
  8. 8. Data Access in Layers
  9. 9. “Operations” Layer
  10. 10. Writing● Use Generic Typing● Has Interface(for testability, etc.)● Handles Exceptions
  11. 11. Reading● Use Mappers
  12. 12. Serializers● Constructed with serializers that convert to types neededby data access layer
  13. 13. Reading
  14. 14. Data Access Layer
  15. 15. Data Access Object● Data Access Object (DAO) is singleton● Transforms from data model to domain model● Operations object configured with serializers to convertfrom data model to domain model● Defines the mappers for read operations
  16. 16. Next Steps
  17. 17. CQL3DataStax:"We believe that CQL3 is a simpler and overall better API for Cassandrathan the thrift API is. Therefore, new projects/applications are encouragedto use CQL3"At eBuddy, we are still using the Thrift API and the Java Hector library.We are currently looking at CQL3 and whether we want to use it goingforward and whether we will "upgrade" existing code.
  18. 18. Structured Data● Object Mapping Frameworks● Mapped vs. Embedded Objects● Nested Properties ("path" access)
  19. 19. Object Mapping Frameworks● Simple mapper frameworks with (some) JPA support● Hector Object Mapper● Kundera● Firebrand (not JPA)● has most features,e.g supports both embedded and mapped object graphshttps://github.com/impetus-opensource/Kunderahttp://github.com/hector-client/hectorhttp://firebrandocm.org
  20. 20. Hierarchical Properties● Use DynamicComposites to model keys that have avariable number of componentsput(“accounts|msn|x.y.z|sign_in”, “0”);put(“accounts|msn|x.y.z|key”, “value”);get(“accounts”) --> retrieved as a map:{"accounts":{ "msn":{ "x.y.z":{ "sign_in": "0","key": "value" } } } }● Use a slice query to retrieve properties using partial path:
  21. 21. Questions?XMSUnlimited messaging.Better. Free.Were Hiring!Download XMS now:

×