Database Reference
In-Depth Information
Storage Service
The Cassandra database service is represented by
org.apache.cassandra.service.Stor-
ageService
. The storage service contains the node's token, which is a marker indicating the
range of data that the node is responsible for.
The server starts up with a call to the
initServer
method of this class, upon which the server
registers the SEDA verb handlers, makes some determinations about its state (such as whether
it was bootstrapped or not, and what its partitioner is), and registers itself as an MBean with the
JMX server.
Messaging Service
The purpose of
org.apache.cassandra.net.MessagingService
is to create socket listeners
for message exchange; inbound and outbound messages from this node come through this ser-
vice. The
MessagingService.listen
method creates a thread. Each incoming connection
then dips into the
ExecutorService
thread pool using
org.apache.cassandra.net.IncomingTcpConnection
(a class that extends
Thread
) to
deserialize the message. The message is validated, and then it's determined whether this is a
streaming message or not. Message streaming is Cassandra's optimized way of sending sections
of SSTable files from one node to another; all other communication between nodes occurs via
serialized messages. If it's streaming, the message is passed to an
IncomingStreamReader
;
if it's not streaming, the message is handled by
MessagingService
is deserialization executor,
which is handed the message in the form of a task that implements
Runnable
. Because this ser-
vice also makes heavy use of stages and the pool it maintains is wrapped with an MBean, you
can find out a lot about how this service is working (whether reads are getting backed up and so
forth) through JMX.
Hinted Handoff Manager
As its name suggests,
org.apache.cassandra.db.HintedHandoffManager
is the class that
manages hinted handoffs internally. To do so it maintains a thread pool, which is available for
JMX monitoring as
HINTED-HANDOFF-POOL
.
Summary
In this chapter, we examined the main pillars of Cassandra's construction, including gossip, anti-
entropy, accrual failure detection, and how the use of a Staged Event-Driven Architecture max-
imizes performance. We also looked at how Cassandra internally executes various operations,