magibney commented on a change in pull request #677: SOLR-13257: support for stable replica routing preferences URL: https://github.com/apache/lucene-solr/pull/677#discussion_r303906601
########## File path: solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java ########## @@ -449,9 +556,83 @@ private static boolean hasReplicaType(Object o, String preferred) { } } + private final ReplicaListTransformerFactory randomRltFactory = (String configSpec, SolrQueryRequest request, + ReplicaListTransformerFactory fallback) -> shufflingReplicaListTransformer; + private ReplicaListTransformerFactory stableRltFactory; + private ReplicaListTransformerFactory defaultRltFactory; + + /** + * Private class responsible for applying pairwise sort based on inherent replica attributes, + * and subsequently reordering any equivalent replica sets according to behavior specified + * by the baseReplicaListTransformer. + */ + private static final class TopLevelReplicaListTransformer implements ReplicaListTransformer { + + private final NodePreferenceRulesComparator replicaComp; + private final ReplicaListTransformer baseReplicaListTransformer; + + public TopLevelReplicaListTransformer(NodePreferenceRulesComparator replicaComp, ReplicaListTransformer baseReplicaListTransformer) { + this.replicaComp = replicaComp; + this.baseReplicaListTransformer = baseReplicaListTransformer; + } + + @Override + public void transform(List<?> choices) { Review comment: True, random-with-seed should work, and I'm open to that. One use case that would benefit from a list-rotation-based implementation (as opposed to random-with-seed) would be if you wanted to set up a tiered or grouped routing system. For example, replication factor of 2, say you have two distinct types of users with different access patterns (that would result in different cache usage patterns). Rather than simply routing deterministically for a given user/request, you could choose one of exactly 2 routing params, bifurcating traffic depending on expected use. With list-rotation, you could specify `routingParam=0` or `routingParam=1` and get the desired behavior; random-with-seed might not work that way, depending on the exact seeds chosen. Granted you could achieve this tiered/grouped routing in other ways, but with a list-rotation-based implementation it would be trivial. The cost, as you say, would be some additional complexity (code-wise, not performance-wise) in `HttpShardHandlerFactory`. In fact, it's this type of use case that I had in mind when providing support for the ability to specify `dividend` directly (as opposed to always hashing the routing param, which would be similarly opaque and thus incompatible with a tiered/grouped routing strategy). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org