> if the replication factor is 3 it just picks the other two nodes following 
> the ring clockwise.

The coordinator for a given mutation is not necessarily a replica (depending on 
whether token-aware routing is used by the client) so it may have to forward to 
RF remote nodes, then wait for the required number of acknowledgements by the 
query's consistency level.

For figuring out the replicas that a write should be forwarded to, see 
StorageProxy.performWrite: 
https://github.com/apache/cassandra/blob/999d263a5ddb9bb33981c39ede3125f199dd61ce/src/java/org/apache/cassandra/service/StorageProxy.java#L1359

Then there ReplicaPlan gets built based on the replication strategy for the 
keyspace, which includes the configuration of full / transient replicas:
https://github.com/apache/cassandra/blob/999d263a5ddb9bb33981c39ede3125f199dd61ce/src/java/org/apache/cassandra/locator/ReplicaPlans.java#L351

WriteResponseHandler is also used on the coordinator path when awaiting 
responses from replicas, to determine when to acknowledge a write back to a 
client.

> On Aug 30, 2023, at 3:46 PM, Gabriel Giussi <gabrielgiu...@gmail.com> wrote:
> 
> I know cassandra uses consistent hashing for choosing the node where a key 
> should go to, and if I understand correctly from this image 
> https://cassandra.apache.org/doc/latest/cassandra/_images/ring.svg 
> if the replication factor is 3 it just picks the other two nodes following 
> the ring clockwise.
> I would like to know if someone can point me to where that is implemented, 
> because I want to implement something similar for the finagle http client, 
> the finagle library already 
> has some implementation of partitioning using consistent hashing, but it 
> doesn't support replication so a key only belongs to a single node, see 
> https://github.com/twitter/util/blob/develop/util-hashing/src/main/scala/com/twitter/hashing/ConsistentHashingDistributor.scala
>  .
> 
> 
> Thanks.

Reply via email to