Database Reference
In-Depth Information
Snitches
Snitches are the way to tell Cassandra about the topology of a cluster, and about nodes' loc-
ations and their proximities. There are two tasks that snitches help Cassandra with. They
are as follows:
Replica placement : As discussed in Chapter 2 , Cassandra Architecture , depend-
ing on the configured replication factor, data gets written to more than one node.
Snitches are the decision-making mechanism that determine where the replicas
should be sent to. An efficient snitch will send place replicas in a manner that
provides the highest availability of data.
Efficient read and write routing : Snitches are all about defining cluster schema,
and thus, they help Cassandra in deciding the most efficient path to perform reads
and writes.
Similar to partitioners, snitches are pluggable. You can plug in your own custom snitch by
extending org.apache.cassandra.locator.EndPointSnitch . The Proper-
tyFileEndPointSnitch class can be used as a guideline on how to write a snitch. To
configure a snitch, you need to alter endpoint_snitch in cassandra.yaml :
endpoint_snitch: SimpleSnitch
For custom snitches, mention the fully qualified class name of the snitch, assuming you
have dropped the custom snitch .class/.jar file in Cassandra's lib directory.
Out of the box, Cassandra provides the snitches detailed in the upcoming sections.
SimpleSnitch
SimpleSnitch is basically a do-nothing snitch. If you see the code, it basically returns
rack1 and datacenter1 for whatever IP address the endpoint has. Since it discards
any information that may be retrieved from the IP address, it is appropriate for installations
where data center related information is not available, or all the nodes are in the same data
center. This is the default snitch.
PropertyFileSnitch
PropertyFileSnitch is a way to explicitly tell Cassandra the relative location of vari-
ous nodes in the clusters. It gives you a means to handpick the nodes to group under a data
center and a rack. The location definition of each node in the cluster is stored in a configur-
Search WWH ::




Custom Search