Cassandra data access

Post on 25-May-2015

2,471 views 4 download

Tags:

description

from Netherlands Cassandra Users Meet Up 28 May 2013

transcript

*

Cassandra Data Access in Java

*

eBuddy use of Cassandra

*

XMS

*

● User Data Service● User Discovery Service● Persistent Session Store● Message History● Location-based Discovery

Cassandra ineBuddy Messaging Platform

*

● 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

*

Data Access - Overview

*

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)

*

Data Access in Layers

*

“Operations” Layer

*

Writing

● Use Generic Typing

● Has Interface(for testability, etc.)

● Handles Exceptions

*

Reading● Use Mappers

*

Serializers● Constructed with serializers that convert to types needed by data access layer

*

Reading

*

Data Access Layer

*

Data Access Object● Data Access Object (DAO) is singleton● Transforms from data model to domain model● Operations object configured with serializers to convert from data model to domain model

● Defines the mappers for read operations

*

Next Steps

*

CQL3

DataStax:"We believe that CQL3 is a simpler and overall better API for Cassandra than the thrift API is. Therefore, new projects/applications are encouraged to 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 going forward and whether we will "upgrade" existing code.

*

Structured Data

● Object Mapping Frameworks● Mapped vs. Embedded Objects

● Nested Properties ("path" access)

*

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 graphs

https://github.com/impetus-opensource/Kundera

http://github.com/hector-client/hector

http://firebrandocm.org

*

Hierarchical Properties

● Use DynamicComposites to model keys that have a variable number of components

put(“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:

*

Questions?

XMSUnlimited messaging. Better. Free.

We're Hiring!

Download XMS now: