Cassandra Python Driver: Force Using A Single Node
Solution 1:
Is it possible to force the Python driver to only connect to that machine?
While sticking the machine in it's own datacenter would work there is another, and perhaps simpler solution. You could use a whitelist policy and only provide it the one node you wish to communicate with.
cluster = Cluster(contact_points=contact_points, load_balancing_policy=WhiteListRoundRobinPolicy(contact_points))
By doing this you can restrict the the driver and have it only contact one node. I would warn you however that if that node goes down your application will go down, as it won't be able to talk to anyone else in the ring.
Solution 2:
Not totally sure what you're trying to accomplish here, but I do have some thoughts if I look at your questions on their own merits. DISCLAIMER: It's something to try...may or may not work.
can I make that machine part of the ring but not holding any data?
One thing you could do here, is to put that machine in its own logical datacenter. Then depending on your replication factor per-keyspace, you could (or could not) have data replicated to it.
Is it possible to force the Python driver to only connect to that machine?
Assuming that you have your one machine in its own logical datacenter (as I suggested above) you can indicate a datacenter to prefer in your connection properties:
cluster = Cluster(
['10.1.1.1'],
load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='DATACENTER_NAME'),
port=9042)
Of course the Python driver would still "discover" the topology of the other nodes via gossip. But, as long as you query at a LOCAL consistency level, your driver should stay with your preferred DC.
Post a Comment for "Cassandra Python Driver: Force Using A Single Node"