dsmiley commented on code in PR #4760:
URL: https://github.com/apache/solr/pull/4760#discussion_r3822685266
##########
solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java:
##########
@@ -342,7 +342,10 @@ private CollectionAdminRequest.MoveReplica
createMoveReplicaRequest(
}
private Replica getRandomReplica(String coll, CloudSolrClient cloudClient)
throws IOException {
- List<Replica> replicas =
cloudClient.getClusterState().getCollection(coll).getReplicas();
+ List<Replica> replicas = new ArrayList<>();
+ for (Slice slice : cloudClient.getClusterState().getCollection(coll)) {
+ replicas.addAll(slice.getReplicas());
+ }
Collections.shuffle(replicas, random());
return replicas.get(0);
Review Comment:
The painful aspect was hardly the list. It was randomizing the entire list
and grabbing the first element. Why do that when we can pick a replica from
the list randomly?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]