SlideShare a Scribd company logo
CASSANDRA COMMUNITY WEBINARS AUGUST 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
AboutThe Last Pickle
Work with clients to deliver and improve
Apache Cassandra based solutions.
Apache Cassandra Committer, DataStax MVP,
Hector Maintainer, 6+ years combined
Cassandra experience.
Based in New Zealand & Austin,TX.
Architecture
Code
www.thelastpickle.com
Cassandra Architecture
API's
Cluster Aware
Cluster Unaware
Clients
Disk
www.thelastpickle.com
Cassandra Cluster Architecture
API's
Cluster Aware
Cluster Unaware
Clients
Disk
API's
Cluster Aware
Cluster Unaware
Disk
Node 1 Node 2
www.thelastpickle.com
Dynamo Cluster Architecture
API's
Dynamo
Database
Clients
Disk
API's
Dynamo
Database
Disk
Node 1 Node 2
www.thelastpickle.com
Architecture
API
Dynamo
Database
www.thelastpickle.com
APITransports
Thrift
Native Binary
www.thelastpickle.com
ThriftTransport
//Custom TServer implementations
o.a.c.thrift.CustomTThreadPoolServer
o.a.c.thrift.CustomTNonBlockingServer
o.a.c.thrift.CustomTHsHaServer
www.thelastpickle.com
APITransports
Thrift
Native Binary
www.thelastpickle.com
Native BinaryTransport
Beta in Cassandra 1.2
Uses Netty
Enabled with
start_native_transport
(Disabled by default)
www.thelastpickle.com
o.a.c.transport.Server.run()
//Setup the Netty server
new ExecutionHandler()
new NioServerSocketChannelFactory()
ServerBootstrap.setPipelineFactory()
www.thelastpickle.com
o.a.c.transport.Message.Dispatcher.messageReceived()
//Process message from client
ServerConnection.validateNewMessage()
Request.execute()
ServerConnection.applyStateTransition()
Channel.write()
www.thelastpickle.com
Messages
Defined in the Native Binary
Protocol
$SRC/doc/native_protocol.spec
www.thelastpickle.com
API Services
JMX
Thrift
CQL 3
www.thelastpickle.com
JMX Management Beans
Spread around the code base.
Interfaces named *MBean
www.thelastpickle.com
JMX Management Beans
Registered with names such as
org.apache.cassandra.db:
type=StorageProxy
www.thelastpickle.com
API Services
JMX
Thrift
CQL 3
www.thelastpickle.com
o.a.c.thrift.CassandraServer
// Implements Thrift Interface
// Access control
// Input validation
// Mapping to/from Thrift and internal types
www.thelastpickle.com
Thrift Interface
Thrift IDL
$SRC/interface/cassandra.thrift
www.thelastpickle.com
o.a.c.thrift.CassandraServer.get_slice()
// get columns for one row
Tracing.begin()
ClientState cState = state()
cState.hasColumnFamilyAccess()
multigetSliceInternal()
www.thelastpickle.com
CassandraServer.multigetSliceInternal()
// get columns for may rows
ThriftValidation.validate*()
// Create ReadCommands
getSlice()
www.thelastpickle.com
CassandraServer.getSlice()
// Process ReadCommands
// return Thrift types
readColumnFamily()
thriftifyColumnFamily()
www.thelastpickle.com
CassandraServer.readColumnFamily()
// Process ReadCommands
// Return ColumnFamilies
StorageProxy.read()
www.thelastpickle.com
API Services
JMX
Thrift
CQL 3
www.thelastpickle.com
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
CQL3 Grammar
ANTLR Grammar
$SRC/o.a.c.cql3/Cql.g
www.thelastpickle.com
o.a.c.cql3.statements.ParsedStatement
// Subclasses generated by ANTLR
// Tracks bound term count
// Prepare CQLStatement
prepare()
www.thelastpickle.com
o.a.c.cql3.statements.CQLStatement
checkAccess(ClientState state)
validate(ClientState state)
execute(ConsistencyLevel cl,
QueryState state,
List<ByteBuffer> variables)
www.thelastpickle.com
statements.SelectStatement.RawStatement
// Implements ParsedStatement
// Input validation
prepare()
www.thelastpickle.com
statements.SelectStatement.execute()
// Create ReadCommands
StorageProxy.read()
www.thelastpickle.com
Architecture
API
Dynamo
Database
www.thelastpickle.com
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
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
o.a.c.service.StorageService
// Ring operations
// Track ring state
// Start & stop ring membership
// Node & token queries
www.thelastpickle.com
o.a.c.service.IResponseResolver
preprocess(MessageIn<T> message)
resolve() throws
DigestMismatchException
RowDigestResolver
RowDataResolver
RangeSliceResponseResolver
www.thelastpickle.com
Response Handlers / Callback
implements IAsyncCallback<T>
response(MessageIn<T> msg)
www.thelastpickle.com
o.a.c.service.ReadCallback.get()
//Wait for blockfor & data
condition.await(timeout,
TimeUnit.MILLISECONDS)
throw ReadTimeoutException()
resolver.resolve()
www.thelastpickle.com
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
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
o.a.c.net.MessagingService.verb<<enum>>
MUTATION
READ
REQUEST_RESPONSE
TREE_REQUEST
TREE_RESPONSE
(And more...)
www.thelastpickle.com
o.a.c.net.MessagingService.verbHandlers
new EnumMap<Verb,
IVerbHandler>(Verb.class)
www.thelastpickle.com
o.a.c.net.IVerbHandler<T>
doVerb(MessageIn<T> message,
String id);
www.thelastpickle.com
o.a.c.net.MessagingService.verbStages
new EnumMap<MessagingService.Verb,
Stage>(MessagingService.Verb.class)
www.thelastpickle.com
o.a.c.net.MessagingService.receive()
runnable = new MessageDeliveryTask(
message, id, timestamp);
StageManager.getStage(
message.getMessageType());
stage.execute(runnable);
www.thelastpickle.com
o.a.c.net.MessageDeliveryTask.run()
// If dropable and rpc_timeout
MessagingService.incrementDroppedMessag
es(verb);
MessagingService.getVerbHandler(verb)
verbHandler.doVerb(message, id)
www.thelastpickle.com
Architecture
API Layer
Dynamo Layer
Database Layer
www.thelastpickle.com
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
o.a.c.concurrent.StageManager
stages = new EnumMap<Stage,
ThreadPoolExecutor>(Stage.class);
getStage(Stage stage)
www.thelastpickle.com
o.a.c.concurrent.Stage
READ
MUTATION
GOSSIP
REQUEST_RESPONSE
ANTI_ENTROPY
(And more...)
www.thelastpickle.com
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
o.a.c.db.Table
// Keyspace
open(String table)
getColumnFamilyStore(String cfName)
getRow(QueryFilter filter)
apply(RowMutation mutation,
boolean writeCommitLog)
www.thelastpickle.com
o.a.c.db.ColumnFamilyStore
// Column Family
getColumnFamily(QueryFilter filter)
getTopLevelColumns(...)
apply(DecoratedKey key,
ColumnFamily columnFamily,
SecondaryIndexManager.Updater
indexer)
www.thelastpickle.com
o.a.c.db.IColumnContainer
addColumn(IColumn column)
remove(ByteBuffer columnName)
ColumnFamily
SuperColumn
www.thelastpickle.com
o.a.c.db.ISortedColumns
addColumn(IColumn column,
Allocator allocator)
removeColumn(ByteBuffer name)
ArrayBackedSortedColumns
AtomicSortedColumns
TreeMapBackedSortedColumns
www.thelastpickle.com
o.a.c.db.Memtable
put(DecoratedKey key,
ColumnFamily columnFamily,
SecondaryIndexManager.Updater
indexer)
flushAndSignal(CountDownLatch latch,
Future<ReplayPosition>
context)
www.thelastpickle.com
o.a.c.db.ReadCommand
getRow(Table table)
SliceByNamesReadCommand
SliceFromReadCommand
www.thelastpickle.com
o.a.c.db.IDiskAtomFilter
getMemtableColumnIterator(...)
getSSTableColumnIterator(...)
IdentityQueryFilter
NamesQueryFilter
SliceQueryFilter
www.thelastpickle.com
Summary
CustomTThreadPoolServer Message.Dispatcher
CassandraServer QueryProcessor
ReadCommand
StorageProxy
IResponseResolver
IAsyncCallback
MessagingService
IVerbHandler
Table ColumnFamilyStore IDiskAtomFilter
API
Dynamo
Database
www.thelastpickle.com
Thanks.
www.thelastpickle.com
Aaron Morton
@aaronmorton
Co-Founder & Principal Consultant
www.thelastpickle.com
Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License

More Related Content

PDF
Cassandra SF 2015 - Repeatable, Scalable, Reliable, Observable Cassandra
PDF
Cassandra Day Atlanta 2016 - Monitoring Cassandra
PDF
Case Study: Troubleshooting Cassandra performance issues as a developer
PDF
Time series databases
PPTX
C*ollege Credit: CEP Distribtued Processing on Cassandra with Storm
PDF
Cassandra hands on
PDF
MySQL under the siege
PPTX
Using Spark to Load Oracle Data into Cassandra
Cassandra SF 2015 - Repeatable, Scalable, Reliable, Observable Cassandra
Cassandra Day Atlanta 2016 - Monitoring Cassandra
Case Study: Troubleshooting Cassandra performance issues as a developer
Time series databases
C*ollege Credit: CEP Distribtued Processing on Cassandra with Storm
Cassandra hands on
MySQL under the siege
Using Spark to Load Oracle Data into Cassandra

What's hot (20)

PDF
Designing The Right Schema To Power Heap (PGConf Silicon Valley 2016)
PDF
Bulletproof Jobs: Patterns For Large-Scale Spark Processing
PPTX
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
PDF
Using script db as a deaddrop to pass data between GAS, JS and Excel
PDF
Event Sourcing with Cassandra (from Cassandra Japan Meetup in Tokyo March 2016)
PDF
In Defense Of Core Data
PPTX
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
PPT
ADO.Net Improvements in .Net 2.0
PDF
3 Dundee-Spark Overview for C* developers
PPTX
Cassandra + Hadoop = Brisk
PDF
Terraforming RDS
PPTX
Updates from Cassandra Summit 2016 & SASI Indexes
PDF
Time series with Apache Cassandra - Long version
PPTX
Scylla Summit 2018: From SAP to Scylla - Tracking the Fleet at GPS Insight
DOCX
SSMS-waitstats
PPTX
Managing a 14 TB reporting datawarehouse with postgresql
PPTX
Lightning Fast Analytics with Cassandra and Spark
PDF
Manchester Hadoop Meetup: Spark Cassandra Integration
PPTX
Angular JS deep dive
PPTX
PHP and Cassandra
Designing The Right Schema To Power Heap (PGConf Silicon Valley 2016)
Bulletproof Jobs: Patterns For Large-Scale Spark Processing
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Using script db as a deaddrop to pass data between GAS, JS and Excel
Event Sourcing with Cassandra (from Cassandra Japan Meetup in Tokyo March 2016)
In Defense Of Core Data
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
ADO.Net Improvements in .Net 2.0
3 Dundee-Spark Overview for C* developers
Cassandra + Hadoop = Brisk
Terraforming RDS
Updates from Cassandra Summit 2016 & SASI Indexes
Time series with Apache Cassandra - Long version
Scylla Summit 2018: From SAP to Scylla - Tracking the Fleet at GPS Insight
SSMS-waitstats
Managing a 14 TB reporting datawarehouse with postgresql
Lightning Fast Analytics with Cassandra and Spark
Manchester Hadoop Meetup: Spark Cassandra Integration
Angular JS deep dive
PHP and Cassandra
Ad

Viewers also liked (7)

PDF
Cassandra - Wellington No Sql
PDF
On Rails with Apache Cassandra
PDF
Nov 2011 HUG: Blur - Lucene on Hadoop
PDF
Cassandra Talk: Austin JUG
PDF
Cassandra for Ruby/Rails Devs
PDF
Partners in Crime: Cassandra Analytics and ETL with Hadoop
ODP
Hadoop and Cassandra at Rackspace
Cassandra - Wellington No Sql
On Rails with Apache Cassandra
Nov 2011 HUG: Blur - Lucene on Hadoop
Cassandra Talk: Austin JUG
Cassandra for Ruby/Rails Devs
Partners in Crime: Cassandra Analytics and ETL with Hadoop
Hadoop and Cassandra at Rackspace
Ad

Similar to Cassandra Community Webinar - August 22 2013 - Cassandra Internals (9)

PDF
C* Summit EU 2013: Cassandra Internals
PDF
Cassandra SF 2013 - Cassandra Internals
PDF
Apache Con NA 2013 - Cassandra Internals
PDF
Apache Cassandra in Bangalore - Cassandra Internals and Performance
PDF
Cassandra 2.1 boot camp, Overview
PDF
Cassandra Community Webinar | In Case of Emergency Break Glass
PDF
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
PDF
NYC Cassandra Day - Java Intro
PDF
Cassandra: Not Just NoSQL, It's MoSQL
C* Summit EU 2013: Cassandra Internals
Cassandra SF 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Cassandra 2.1 boot camp, Overview
Cassandra Community Webinar | In Case of Emergency Break Glass
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
NYC Cassandra Day - Java Intro
Cassandra: Not Just NoSQL, It's MoSQL

More from aaronmorton (13)

PDF
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
PDF
Cassandra SF Meetup - CQL Performance With Apache Cassandra 3.X
PDF
Cassandra London March 2016 - Lightening talk - introduction to incremental ...
PDF
Cassandra sf 2015 - Steady State Data Size With Compaction, Tombstones, and TTL
PDF
Cassandra TK 2014 - Large Nodes
PDF
Cassandra SF 2013 - In Case Of Emergency Break Glass
PDF
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
KEY
Cassandra SF 2012 - Technical Deep Dive: query performance
KEY
Hello @world #cassandra
KEY
Cassandra does what ? Code Mania 2012
PDF
Nzpug welly-cassandra-02-12-2010
PDF
Introduction to Cassandra
PDF
Building a distributed Key-Value store with Cassandra
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra SF Meetup - CQL Performance With Apache Cassandra 3.X
Cassandra London March 2016 - Lightening talk - introduction to incremental ...
Cassandra sf 2015 - Steady State Data Size With Compaction, Tombstones, and TTL
Cassandra TK 2014 - Large Nodes
Cassandra SF 2013 - In Case Of Emergency Break Glass
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra SF 2012 - Technical Deep Dive: query performance
Hello @world #cassandra
Cassandra does what ? Code Mania 2012
Nzpug welly-cassandra-02-12-2010
Introduction to Cassandra
Building a distributed Key-Value store with Cassandra

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Modernizing your data center with Dell and AMD
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Modernizing your data center with Dell and AMD
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx

Cassandra Community Webinar - August 22 2013 - Cassandra Internals