C* Summit EU 2013: Cassandra Internals
Upcoming SlideShare
Loading in...5
×
 

C* Summit EU 2013: Cassandra Internals

on

  • 1,147 views

Speaker: Aaron Morton, Apache Cassandra Committer & Co-Founder/Principle Consultant at The Last Pickle Inc. ...

Speaker: Aaron Morton, Apache Cassandra Committer & Co-Founder/Principle Consultant at The Last Pickle Inc.
Video: http://www.youtube.com/watch?v=efI5fL8eEfo&list=PLqcm6qE9lgKLoYaakl3YwIWP4hmGsHm5e&index=23
From the microsecond your request hits an Apache Cassandra node there are many code paths, threads and machines involved in storing or fetching your data. This talk will step through the common operations and highlight the code responsible. Apache Cassandra solves many interesting problems to provide a scalable, distributed, fault tolerant database. Cluster wide operations track node membership, direct requests and implement consistency guarantees. At the node level, the Log Structured storage engine provides high performance reads and writes. All of this is implemented in a Java code base that has greatly matured over the past few years. This talk will step through read and write requests, automatic processes and manual maintenance tasks. I'll discuss the general approach to solving the problem and drill down to the code responsible for implementation. Existing Cassandra users, those wanting to contribute to the project and people interested in Dynamo based systems will all benefit from this tour of the code base.

Statistics

Views

Total Views
1,147
Views on SlideShare
1,142
Embed Views
5

Actions

Likes
2
Downloads
47
Comments
0

2 Embeds 5

http://23.253.69.203 4
http://localhost 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

C* Summit EU 2013: Cassandra Internals C* Summit EU 2013: Cassandra Internals Presentation Transcript

  • 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