Project Casquatch is a database abstraction layer with code generation designed to streamline Cassandra development. Out of the box it comes pre-tuned with high available policies including load balancing, geo-redundancy, connection pooling, etc., sitting on top of the DataStax driver using native APIs. All of this is abstracted behind the ever prevalent POJO. Instead of writing CQL, we utilize generic programming that allows you to simply pass a generated POJO to a save() method or populate with a getById(). This is the same code reportedly used by T-Mobile for multiple national platforms including the activation of the Apple Watch and Galaxy Watch, T-Mobile Payments, Digits, and many others.
As presented at Seattle Cassandra Users Group on June . 26th, 2019.
3. 3Public
Josh Turner
Principal Engineer @ T-Mobile
Distributed Data Systems
Lead
Software Development
Engineering
/turnerjosh /tdl-jturner
Who am I & Where do I come from?
9. 9
Distributed, wide column store,
NoSQL Database
Masterless Architecture
Tunable Consistency / AP Design
Query Language : CQL
What is Cassandra?
Public
10. 10
Cassandra Made Easy!
Java Abstraction Layer For Cassandra
Pre-tuned For Enterprise Best
Practices
Object Oriented Code Generation
Simple Object Based API
Java Spring Boot Framework
Integration
What is Casquatch?
Public
11. 11
Load Balancing / Geo Redundancy
Connection Pooling
Reconnection & Retry Policy
Data Caching
Workload Filtering
Security
What do I get?
Public
13. 13
Open Source Only Model
T-Mobile Open Source Group
https://opensource.t-mobile.com
Project Casquatch
https://github.com/tmobile/casquatch
JavaDocs
https://tmobile.github.io/casquatch/
Open Source
Public
14. 14
We recognize that there is a wide range of
platforms, and T-Mobile can't address them
all. This is why we open sourced
Casquatch -- we hope the community will
be able to expand how Casquatch is
used. As with any tool, consult with your IT
department before using in production.
All code samples included are for
demonstration purposes only.
Licensed under Apache 2.0
https://www.apache.org/licenses/LICENSE-2.0
Open Source
Public
17. 1717
We started with Spring Data
All the testing went great… Until
production
We didn’t know what we didn’t
know…
Tried to fix Spring
Decided to build and integrate
How did I get here?
Public
18. 1818
Spring Data
No High Availability
No Retry
Non Industry Best Practices
Casquatch
Highly Available
Automatic Retry
Follows Industry Best Practices
Savings
Significant reduction in support and design cost
Highly Reliable Architecture
How does it compare?
Public
19. 1919
Spring Data - Developer Effort
~150 Lines For Basic Configuration
~100 Lines Per Table
~10 Tables Per App
Casquatch - Developer Effort
~10 lines of code
Savings
1100+ lines of code and days of developer
time for each application
How muchdo I have to write?
Public
20. 2020
Command Line Interface
Driven by Table Metadata
Annotated Objects
Customizable
Code Generator
Public
21. 2121
Hosted by Sonatype
Available in Maven Central
Include in pom.xml
Maven
Public
22. 2222
Optional Spring Boot Integration
Add Import to Application.java
Dependency Injection
Spring Boot Integration
Public
23. 2323
Skip Spring Boot
Builder Pattern
CassandraDriver.builder().withUsern
ame() … .build()
All properties are available
If You BuildIt…
Public
25. 25Public
Standard
application.properties
The Basics
Credentials, Contact Points,
Keyspace, etc
The Advanced
Connection Limits, LoadBalancing,
Timeout, SSL, etc
Many More in README.md
Spring Boot Configuration:
Code For Demonstration Purposes Only
26. 26Public
Skip Spring Boot and Do It Yourself
The Basics
Credentials, Contact Points,
Keyspace, etc
The Advanced
Connection Limits, LoadBalancing,
Timeout, SSL, etc
Many More in API Docs
Builder Pattern:
Code For Demonstration Purposes Only
27. 27Public
Create a Cassandra Table
Columns use _ for spaces
Supports all data types
Supports UDT
Create Schema:
Code For Demonstration Purposes Only
28. 28Public
Run the code generator
Read in settings on command line
or from properties file
Configurable options
More in README.md
Create Some Code:
Code For Demonstration Purposes Only
29. 29Public
Custom Package
Only Required Imports
Get Some Code: tableName.java
Code For Demonstration Purposes Only
30. 30Public
Comments
Full CQL
Annotated
Get Some Code: tableName.java
Code For Demonstration Purposes Only
32. 32Public
Package option creates pom.xml
Snippet shorted for slide
Complete Artifact
Get Some Code: pom.xml
Code For Demonstration Purposes Only
33. 33Public
T getById(Class<T> c, T o) : Get by passing an object instance with the key
populated.
void save(Class<T> c, T o) : Save by passing an object instance.
void delete(Class<T> c, T o): Delete by passing an object instance with the key
populated
Use The Code:
Code For Demonstration Purposes Only
35. 35Public
Run the code generator with a –
dao
Generate the Data Access Object
REST APIs
Deployable Microservice
Unit Tested with Mockito
Generate a DAO
Code For Demonstration Purposes Only
36. 36Public
Swagger UI Integration
Basic Casquatch APIs exposed
Wrapped in Request/Response
payload objects
Simple JSON interface
Clean error messaging and status
codes
DAO - Swagger
Code For Demonstration Purposes Only