SlideShare a Scribd company logo
CASSANDRA EU 2013	


CASSANDRA
INTERNALS	

Aaron Morton	

@aaronmorton	

!

Co-Founder & Principal Consultant	

www.thelastpickle.com
Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License

#CassandraEU
About The Last Pickle.

Work with clients to deliver and improve
Apache Cassandra based solutions.
	

Apache Cassandra Committer, DataStax MVP,
Hector Maintainer, Apache Usergrid Committer.
Based in New Zealand & Austin, TX.

www.thelastpickle.com

#CassandraEU
Architecture
Code
www.thelastpickle.com

#CassandraEU
Cassandra Architecture.
Clients

API's

Cluster Aware

Cluster Unaware

Disk

www.thelastpickle.com

#CassandraEU
Cassandra Cluster Architecture.
Clients

API's

Cluster Aware

Cluster Aware

Cluster Unaware

Cluster Unaware

Disk

Disk

Node 1

www.thelastpickle.com

API's

Node 2

#CassandraEU
Dynamo Cluster Architecture.
Clients

API's

Dynamo

Dynamo

Database

Database

Disk

Disk

Node 1

www.thelastpickle.com

API's

Node 2

#CassandraEU
Architecture
API
Dynamo
Database
www.thelastpickle.com

#CassandraEU
API Transports.
!

	

 Thrift
Native Binary
!

www.thelastpickle.com

#CassandraEU
Thrift Transport.
!

//Custom TServer implementations
o.a.c.thrift.CustomTThreadPoolServer
o.a.c.thrift.CustomTHsHaServer

www.thelastpickle.com

#CassandraEU
API Transports.

www.thelastpickle.com

	

 Thrift
Native Binary

#CassandraEU
Native Binary Transport.
!

	

 Beta in Cassandra 1.2, now GA.
Uses Netty.
CQL 3 only.
www.thelastpickle.com

#CassandraEU
o.a.c.transport.Server.run()
!

//Setup the Netty server
new ExecutionHandler()
new NioServerSocketChannelFactory()
ServerBootstrap.setPipelineFactory()

www.thelastpickle.com

#CassandraEU
o.a.c.transport.Message.Dispatcher.messageReceived()
!

//Process message from client
ServerConnection.validateNewMessage()
Request.execute()
ServerConnection.applyStateTransition()
Channel.write()

www.thelastpickle.com

#CassandraEU
Messages.
!

Defined in the Native Binary
Protocol
$SRC/doc/native_protocol.spec

www.thelastpickle.com

#CassandraEU
API Services.
!

	

 JMX
Thrift
CQL 3
!

www.thelastpickle.com

#CassandraEU
JMX Management Beans.
!

	

 Spread around the code
base.
Interfaces named *MBean
www.thelastpickle.com

#CassandraEU
JMX Management Beans.
!

	

 Registered with names such
as org.apache.cassandra.db:
type=StorageProxy

www.thelastpickle.com

#CassandraEU
API Services.
!

	

 JMX
Thrift
CQL 3
!

www.thelastpickle.com

#CassandraEU
o.a.c.thrift.CassandraServer
!

// Implements Thrift Interface
// Access control
// Input validation
// Mapping to/from Thrift and internal types

www.thelastpickle.com

#CassandraEU
Thrift Interface.
!

Thrift IDL

$SRC/interface/cassandra.thrift

www.thelastpickle.com

#CassandraEU
o.a.c.thrift.CassandraServer.get_slice()
!

// get columns for one row
Tracing.begin()
ClientState cState = state()
cState.hasColumnFamilyAccess()

multigetSliceInternal()
!

www.thelastpickle.com

#CassandraEU
CassandraServer.multigetSliceInternal()
!

// get columns for may rows
ThriftValidation.validate*()
// Create ReadCommands
getSlice()
!

www.thelastpickle.com

#CassandraEU
CassandraServer.getSlice()
!

// Process ReadCommands
// return Thrift types
!

readColumnFamily()
thriftifyColumnFamily()
!

www.thelastpickle.com

#CassandraEU
CassandraServer.readColumnFamily()
!

// Process ReadCommands
// Return ColumnFamilies
!

StorageProxy.read()
!

www.thelastpickle.com

#CassandraEU
API Services.
!

	

 JMX
Thrift
CQL 3
!

www.thelastpickle.com

#CassandraEU
o.a.c.cql3.QueryProcessor
!

// Prepares and executes CQL3 statements
// Used by Thrift & Native transports
// Access control
// Input validation
// Returns transport.ResultMessage
!
!

www.thelastpickle.com

#CassandraEU
CQL3 Grammar.
!

ANTLR Grammar
$SRC/o.a.c.cql3/Cql.g

www.thelastpickle.com

#CassandraEU
o.a.c.cql3.statements.ParsedStatement
!

// Subclasses generated by ANTLR
// Tracks bound term count
// Prepare CQLStatement
prepare()

www.thelastpickle.com

#CassandraEU
o.a.c.cql3.statements.CQLStatement
!

checkAccess(ClientState state)
validate(ClientState state)
execute(ConsistencyLevel cl,

 
 
 
 
 QueryState state,

 
 
 
 
 List<ByteBuffer> variables)

www.thelastpickle.com

#CassandraEU
statements.SelectStatement.RawStatement
!

// Implements ParsedStatement
// Input validation
prepare()

www.thelastpickle.com

#CassandraEU
statements.SelectStatement.execute()
!

// Create ReadCommands
StorageProxy.read()

www.thelastpickle.com

#CassandraEU
Architecture
API
Dynamo
Database
www.thelastpickle.com

#CassandraEU
Dynamo Layer.

o.a.c.service
o.a.c.net
!

o.a.c.dht
o.a.c.gms
o.a.c.locator
o.a.c.stream
www.thelastpickle.com

#CassandraEU
o.a.c.service.StorageProxy
!

// Cluster wide storage operations
// Select endpoints & check CL available
// Send messages to Stages
// Wait for response
// Store Hints
www.thelastpickle.com

#CassandraEU
o.a.c.service.StorageService
!

// Ring operations
// Track ring state
// Start & stop ring membership
// Node & token queries

www.thelastpickle.com

#CassandraEU
o.a.c.service.IResponseResolver
!

preprocess(MessageIn<T> message)
resolve() throws 
 DigestMismatchException
!

RowDigestResolver
RowDataResolver
RangeSliceResponseResolver

www.thelastpickle.com

#CassandraEU
Response Handlers / Callback.

implements IAsyncCallback<T>
!

response(MessageIn<T> msg)
!

www.thelastpickle.com

#CassandraEU
o.a.c.service.ReadCallback.get()
//Wait for blockfor & data response
condition.await(timeout,

 TimeUnit.MILLISECONDS)
!

throw ReadTimeoutException()
!

resolver.resolve()
www.thelastpickle.com

#CassandraEU
o.a.c.service.StorageProxy.fetchRows()
!

getLiveSortedEndpoints()
new RowDigestResolver()
new ReadCallback()
MessagingService.sendRR()
--------------------------------------ReadCallback.get() # blocking
catch (DigestMismatchException ex)
catch (ReadTimeoutException ex)
www.thelastpickle.com

#CassandraEU
Dynamo Layer
!

o.a.c.service
o.a.c.net
!

o.a.c.dht
o.a.c.gms
o.a.c.locator
o.a.c.stream
www.thelastpickle.com

#CassandraEU
o.a.c.net.MessagingService.verb<<enum>>
!

MUTATION
READ
REQUEST_RESPONSE
TREE_REQUEST
TREE_RESPONSE
(And more...)
www.thelastpickle.com

#CassandraEU
o.a.c.net.MessagingService.verbHandlers
!

new EnumMap<Verb,


 
 IVerbHandler>(Verb.class)

www.thelastpickle.com

#CassandraEU
o.a.c.net.IVerbHandler<T>
!

doVerb(MessageIn<T> message,


 
 
 
 String id);
!

www.thelastpickle.com

#CassandraEU
o.a.c.net.MessagingService.verbStages
!

new EnumMap<MessagingService.Verb, 

 
 
 Stage>(MessagingService.Verb.class)

www.thelastpickle.com

#CassandraEU
o.a.c.net.MessagingService.receive()
!

runnable = new MessageDeliveryTask(

 
 message, id, timestamp);
!

StageManager.getStage(

 
 message.getMessageType());
!

stage.execute(runnable);
www.thelastpickle.com

#CassandraEU
o.a.c.net.MessageDeliveryTask.run()
!

// If dropable and rpc_timeout
MessagingService.incrementDroppedMessages(v
erb);
return;
!

MessagingService.getVerbHandler(verb)
verbHandler.doVerb(message, id)
www.thelastpickle.com

#CassandraEU
Architecture
API Layer
Dynamo Layer
Database Layer
www.thelastpickle.com

#CassandraEU
Database Layer
!

o.a.c.concurrent
o.a.c.db
!

o.a.c.cache
o.a.c.io
o.a.c.trace
www.thelastpickle.com

#CassandraEU
o.a.c.concurrent.StageManager
!

stages = new EnumMap<Stage,
ThreadPoolExecutor>(Stage.class);
!

getStage(Stage stage)

www.thelastpickle.com

#CassandraEU
o.a.c.concurrent.Stage
!

READ
MUTATION
GOSSIP
REQUEST_RESPONSE
ANTI_ENTROPY
(And more...)
www.thelastpickle.com

#CassandraEU
Database Layer.

o.a.c.concurrent
o.a.c.db
!

o.a.c.cache
o.a.c.io
o.a.c.trace
www.thelastpickle.com

#CassandraEU
o.a.c.db.Table
!

// Keyspace
open(String table)
getColumnFamilyStore(String cfName)
!

getRow(QueryFilter filter)
apply(RowMutation mutation,

 
 
 
 boolean writeCommitLog)
www.thelastpickle.com

#CassandraEU
o.a.c.db.ColumnFamilyStore
!

// Column Family
getColumnFamily(QueryFilter filter)
getTopLevelColumns(...)
!

apply(DecoratedKey key,

 
 
 
 ColumnFamily columnFamily,

 
 
 
 SecondaryIndexManager.Updater 
 
 
 
indexer)
www.thelastpickle.com

#CassandraEU
o.a.c.db.IColumnContainer
!

addColumn(IColumn column)
remove(ByteBuffer columnName)
!

ColumnFamily
SuperColumn
!

(Removed in 2.0)
www.thelastpickle.com

#CassandraEU
o.a.c.db.ISortedColumns
!

addColumn(IColumn column,

 
 
 
 
 
 
 Allocator allocator)
removeColumn(ByteBuffer name)
!

ArrayBackedSortedColumns
AtomicSortedColumns
TreeMapBackedSortedColumns
www.thelastpickle.com

#CassandraEU
o.a.c.db.Memtable
!

put(DecoratedKey key,

 
 
 ColumnFamily columnFamily,
SecondaryIndexManager.Updater
indexer)
!

flushAndSignal(CountDownLatch latch,

 
 
 
 
 
 
 
 
 
 Future<ReplayPosition> 

 

 
 
 
 
 
 
 context)
www.thelastpickle.com

#CassandraEU
o.a.c.db.ReadCommand
!

getRow(Table table)
!

SliceByNamesReadCommand
SliceFromReadCommand
RangeSliceCommand
(Additional classes for paging in 2.0)

www.thelastpickle.com

#CassandraEU
o.a.c.db.IDiskAtomFilter
!

getMemtableColumnIterator(...)
getSSTableColumnIterator(...)
!

IdentityQueryFilter
NamesQueryFilter
SliceQueryFilter

www.thelastpickle.com

#CassandraEU
Summary
CustomTThreadPoolServer

Message.Dispatcher

CassandraServer

API

QueryProcessor

Dynamo

ReadCommand
StorageProxy
IResponseResolver
IAsyncCallback
MessagingService
IVerbHandler

Table

www.thelastpickle.com

ColumnFamilyStore

IDiskAtomFilter

Database

#CassandraEU
Thanks.

	


!

www.thelastpickle.com

#CassandraEU
Aaron Morton	

@aaronmorton	

www.thelastpickle.com	

!

Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License

More Related Content

PDF
Sparkstreaming
PDF
Cassandra Community Webinar | In Case of Emergency Break Glass
PDF
Advanced Apache Cassandra Operations with JMX
PDF
The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...
PPTX
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
PPTX
Understanding DSE Search by Matt Stump
PDF
Lessons from Cassandra & Spark (Matthias Niehoff & Stephan Kepser, codecentri...
PDF
OpenStack LA meetup Feb 18, 2015
Sparkstreaming
Cassandra Community Webinar | In Case of Emergency Break Glass
Advanced Apache Cassandra Operations with JMX
The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
Understanding DSE Search by Matt Stump
Lessons from Cassandra & Spark (Matthias Niehoff & Stephan Kepser, codecentri...
OpenStack LA meetup Feb 18, 2015

What's hot (18)

PDF
PagerDuty: One Year of Cassandra Failures
PDF
The Automation Factory
PDF
Apache cassandra en production - devoxx 2017
PPTX
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
PDF
Top Node.js Metrics to Watch
PPTX
Cassandra Community Webinar: Back to Basics with CQL3
PDF
Zookeeper
PPTX
Apache cassandra v4.0
PDF
Cassandra EU - Data model on fire
PDF
Go Programming Patterns
PDF
How Prometheus Store the Data
ODP
Meetup cassandra sfo_jdbc
PDF
Nuvola: a tale of migration to AWS
PPT
SparkSQL et Cassandra - Tool In Action Devoxx 2015
PDF
Apache Whirr
PDF
Bottom to Top Stack Optimization - CICON2011
PDF
Compliance as Code with terraform-compliance
PDF
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
PagerDuty: One Year of Cassandra Failures
The Automation Factory
Apache cassandra en production - devoxx 2017
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Top Node.js Metrics to Watch
Cassandra Community Webinar: Back to Basics with CQL3
Zookeeper
Apache cassandra v4.0
Cassandra EU - Data model on fire
Go Programming Patterns
How Prometheus Store the Data
Meetup cassandra sfo_jdbc
Nuvola: a tale of migration to AWS
SparkSQL et Cassandra - Tool In Action Devoxx 2015
Apache Whirr
Bottom to Top Stack Optimization - CICON2011
Compliance as Code with terraform-compliance
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
Ad

Viewers also liked (6)

DOC
EspañOl
PDF
C* Summit 2013: Hardware Agnostic - Cassandra on Raspberry Pi by Andy Cobley
PPT
The Virtuous Republic
DOC
Patient Access Specialist
PPTX
Introduction to DataStax Enterprise Advanced Replication with Apache Cassandra
PPTX
Introduction to DataStax Enterprise Graph Database
EspañOl
C* Summit 2013: Hardware Agnostic - Cassandra on Raspberry Pi by Andy Cobley
The Virtuous Republic
Patient Access Specialist
Introduction to DataStax Enterprise Advanced Replication with Apache Cassandra
Introduction to DataStax Enterprise Graph Database
Ad

Similar to C* Summit EU 2013: Cassandra Internals (19)

PDF
Cassandra Community Webinar: Apache Cassandra Internals
PDF
Cassandra Community Webinar - August 22 2013 - Cassandra Internals
PDF
Apache Cassandra in Bangalore - Cassandra Internals and Performance
PDF
Cassandra SF 2013 - Cassandra Internals
PDF
Apache Con NA 2013 - Cassandra Internals
PDF
Jan 2015 - Cassandra101 Manchester Meetup
PPTX
VoxxedDays Luxembourg 2019
PDF
Introduction to Apache Cassandra
PDF
Cassandra 2.0 to 2.1
PPTX
Виталий Бондаренко "Fast Data Platform for Real-Time Analytics. Architecture ...
PPTX
Devops kc
PDF
Stampede con 2014 cassandra in the real world
PPTX
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
PDF
Paris Cassandra Meetup - Cassandra for Developers
PDF
Cassandra Workshop - Cassandra from scratch in one day
PPTX
An Overview of Apache Cassandra
PDF
C* Summit EU 2013: No Whistling Required: Cabs, Cassandra, and Hailo
PPTX
DataStax NYC Java Meetup: Cassandra with Java
PDF
Cassandra's Odyssey @ Netflix
Cassandra Community Webinar: Apache Cassandra Internals
Cassandra Community Webinar - August 22 2013 - Cassandra Internals
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Cassandra SF 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
Jan 2015 - Cassandra101 Manchester Meetup
VoxxedDays Luxembourg 2019
Introduction to Apache Cassandra
Cassandra 2.0 to 2.1
Виталий Бондаренко "Fast Data Platform for Real-Time Analytics. Architecture ...
Devops kc
Stampede con 2014 cassandra in the real world
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
Paris Cassandra Meetup - Cassandra for Developers
Cassandra Workshop - Cassandra from scratch in one day
An Overview of Apache Cassandra
C* Summit EU 2013: No Whistling Required: Cabs, Cassandra, and Hailo
DataStax NYC Java Meetup: Cassandra with Java
Cassandra's Odyssey @ Netflix

More from DataStax Academy (20)

PDF
Forrester CXNYC 2017 - Delivering great real-time cx is a true craft
PPTX
Cassandra on Docker @ Walmart Labs
PDF
Cassandra 3.0 Data Modeling
PPTX
Cassandra Adoption on Cisco UCS & Open stack
PDF
Data Modeling for Apache Cassandra
PDF
Coursera Cassandra Driver
PDF
Production Ready Cassandra
PDF
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
PPTX
Cassandra @ Sony: The good, the bad, and the ugly part 1
PPTX
Cassandra @ Sony: The good, the bad, and the ugly part 2
PDF
Standing Up Your First Cluster
PDF
Real Time Analytics with Dse
PDF
Introduction to Data Modeling with Apache Cassandra
PDF
Cassandra Core Concepts
PPTX
Enabling Search in your Cassandra Application with DataStax Enterprise
PPTX
Bad Habits Die Hard
PDF
Advanced Data Modeling with Apache Cassandra
PDF
Advanced Cassandra
PDF
Apache Cassandra and Drivers
PDF
Getting Started with Graph Databases
Forrester CXNYC 2017 - Delivering great real-time cx is a true craft
Cassandra on Docker @ Walmart Labs
Cassandra 3.0 Data Modeling
Cassandra Adoption on Cisco UCS & Open stack
Data Modeling for Apache Cassandra
Coursera Cassandra Driver
Production Ready Cassandra
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Sony: The good, the bad, and the ugly part 1
Cassandra @ Sony: The good, the bad, and the ugly part 2
Standing Up Your First Cluster
Real Time Analytics with Dse
Introduction to Data Modeling with Apache Cassandra
Cassandra Core Concepts
Enabling Search in your Cassandra Application with DataStax Enterprise
Bad Habits Die Hard
Advanced Data Modeling with Apache Cassandra
Advanced Cassandra
Apache Cassandra and Drivers
Getting Started with Graph Databases

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
sap open course for s4hana steps from ECC to s4
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

C* Summit EU 2013: Cassandra Internals