scalacassandraphantom-dsl

Implementing multi-datacenter Cassandra with Phantom driver


I'm working with Cassandra 3.x and Phantom driver (scala), and modifying my Cassandra deployment from a simple, three nodes cluster to a multi datacenter Cassandra deployment that consists of two datacenters:

  1. Transactional - the "main" datacenter, to which all reads/writes occur (except for reads/writes done by some analytics job).
  2. Analytics - a datacenter used for analytics purposes only. The analytics job should operate (i.e. read/write to) on this datacenter.

Both datacenters are configured with the proper snitch and replication factor strategies.

Based on this article ("Workload Separation" section), I'm supposed to be able to read/write from the "Transactional" datacenter, and run analytics jobs on the "Analytics" datacenter however, I'm not sure how to get this to work with the phantom driver.

How can I configure the driver to read/write from the proper datacenter?

Will setting the hosts in ContactPoints class to nodes from the Transactional datacenter only do the trick?


Solution

  • By default, Java driver 3.x uses so-called DCAware load balancing policy combined with TokenAware policy. Data center could be configured explicitly by using withLocalDc function of builder, but it could be omitted and driver will use the datacenter of the first contact point that was reached at initialization. So you can just point Phantom only to servers in the transactional DC, and it will work only with it (until you're using non-local consistency levels, such as QUORUM/SERIAL, EACH_QUORUM, etc.)