How does token aware behave when statement has token function

81 views
Skip to first unread message

siddharth verma

unread,
Sep 16, 2016, 1:56:21 PM9/16/16
to java-dri...@lists.datastax.com
Hi,
I was curious as to how does token aware policy behave when we specify the token range in the statement.
1. If the entire token range is on 1 node
2. the token range lies on two nodes.

Does driver change the coordinator accordingly? According to page of ResultSet, how does it determine next coordinator?

Thanks
Siddharth Verma

Olivier Michallat

unread,
Sep 16, 2016, 4:03:27 PM9/16/16
to java-dri...@lists.datastax.com
Hi,

The token-aware policy relies entirely on the statement's getKeyspace() and getRoutingKey(), which may or may not be computed automatically as explained here:

Currently the only way the routing key can be computed automatically is if your query does an exact match on all the partition key components. So it won't work with a token range, you can verify that by calling statement.getRoutingKey() which will be null.
As you suggest, if the entire token range is on 1 node, it makes sense to route the query, but you'll have to do it manually, i.e. call setRoutingKey() with a partition key that falls into the range. Incidentally I just noticed that BoundStatement doesn't have the overload with a vararg, I'll open a ticket for that.

I see what you mean with paging, but token-aware routing is not that sophisticated. If a routing key is set on a statement, it will be used for all pages, otherwise the query is not routed, i.e. the token-aware policy acts as a pass-through and the coordinator will be determined by the child policy.
In theory the server could also return the routing key for the next page, but that sounds quite complicated to implement. If you want to pursue that idea I would suggest emailing the Apache Cassandra user list. 
 

--

Olivier Michallat

Driver & tools engineer, DataStax


--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.

Reply all
Reply to author
Forward
0 new messages