Paris Cassandra Meetup - Overview of New Cassandra Drivers
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Paris Cassandra Meetup - Overview of New Cassandra Drivers

  • 1,737 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,737
On Slideshare
1,702
From Embeds
35
Number of Embeds
2

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 35

https://twitter.com 34
https://si0.twimg.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Overview of NewCassandra DriversMichaël FiguièreEngineer & Developer Advocate, DataStax@mfiguiere
  • 2. Past Drivers Architecture Thrift API OO API Thrift RPC Client Library * This is a simplified view of drivers architecture. Details vary from one language to another.©2012 DataStax 2
  • 3. Current Drivers Architecture CQL API Thrift API OO API DB API Thrift RPC Thrift RPC Client Library CQL Driver * This is a simplified view of drivers architecture. Details vary from one language to another.©2012 DataStax 3
  • 4. CQL: the new face of Cassandra • CQL 3 • Simpler Data Model using denormalized Tables • SQL-like query language • Schema definition • CQL Binary Protocol • To be introduced in Cassandra 1.2 (CASSANDRA-2478) • Designed for CQL 3 • Opens doors for Streaming, Notifications, ... • Thrift will keep being supported by Cassandra©2012 DataStax 4
  • 5. New Drivers Architecture DB API CQL API OO API CQL Native Protocol Next Generation Driver * This is a simplified view of drivers architecture. Details vary from one language to another.©2012 DataStax 5
  • 6. Request Pipelining Client Cassandra Without Request Pipelining With Client Cassandra Request Pipelining©2012 DataStax 6
  • 7. Notifications Node Client Node Node Without Notifications With Notifications Node Client Node Node©2012 DataStax 7
  • 8. Java Driver • Reference Implementation • Asynchronous architecture based on Netty • Prepared Statements Support • Automatic Fail-over • Node Discovery • Cassandra Tracing Support • Tunable policies • LoadBalancingPolicy • ReconnectionPolicy •©2012 DataStax RetryPolicy 8
  • 9. Connect and Write Cluster cluster = new Cluster.Builder() .addContactPoints("127.0.0.1", "127.0.0.2") .build(); Session session = cluster.connect(); session.execute( "INSERT INTO user (user_id, name, email) VALUES (12345, johndoe, john@doe.com)" );©2012 DataStax 9
  • 10. Read ResultSet rs = session.execute("SELECT * FROM test"); List<CQLRow> rows = rs.fetchAll(); for (CQLRow row : rows) { String userId = row.getString("user_id"); String name = row.getString("name"); String email = row.getString("email"); }©2012 DataStax 10
  • 11. Asynchronous Read ResultSet.Future future = session.executeAsync("SELECT * FROM test"); ResultSet rs = future.get(); List<CQLRow> rows = rs.fetchAll(); for (CQLRow row : rows) { String userId = row.getString("user_id"); String name = row.getString("name"); String email = row.getString("email"); }©2012 DataStax 11
  • 12. Mapping in Java • JPA • Standard and very popular API • Very relational oriented • Hard for developers to figure out which part is usable • JPA-ish • A mapping API designed for Cassandra • Most annotations borrowed and modified from JPA • Get rid of non relevant components • Add some Cassandra-specific concepts©2012 DataStax 12
  • 13. Object Mapping @Table("user_and_messages") public enum Gender { public class User { @EnumValue("m") @Column("user_id") MALE, private String userId; @EnumValue("f") private String name; FEMALE; } private String email; private Gender gender; }©2012 DataStax 13
  • 14. Sample Data Modeluser_and_messages Table user_id msg_id title body gmason 4 Hello! Give me liberty or give me death gmason 5 Bonjour ! I chopped down the cherry tree ahamilton 7 Hallo ! A government of laws, not men ahamilton 9 ¡Hola I chopped down the cherry tree CQL CREATE TABLE user_and_messages ( user_id varchar, msg_id int, title varchar, body varchar, PRIMARY KEY (user_id, msg_id));©2012 DataStax 14
  • 15. Aggregation user_id msg_id title body gmason 4 Hello! Give me liberty or give me death gmason 5 Bonjour ! I chopped down the cherry tree ahamilton 7 Hallo ! A government of laws, not men ahamilton 9 ¡Hola I chopped down the cherry tree @Table("user_and_messages") public class Message { public class User { private String title; @Column("user_id") private String userId; private String body; } @GroupBy("user_id") private List<Message> messages; }©2012 DataStax 15
  • 16. Inheritance@Table("catalog") @InheritanceValue("tv")@Inheritance({Phone.class, TV.class}) public class TV@InheritanceColumn("product_type") extends Product {public abstract class Product { private float size; @Column("product_id") } private String productId; private float price; private String vendor; private String model;}©2012 DataStax 16
  • 17. Now Available! https://github.com/datastax/java-driver
  • 18. Stay Tuned! blog.datastax.com @mfiguiere