bruno-roustant commented on code in PR #2885:
URL: https://github.com/apache/solr/pull/2885#discussion_r1862179675


##########
solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java:
##########
@@ -1145,40 +1123,32 @@ protected String getRemoteCoreUrl(String 
collectionName, String origCorename)
           "No active replicas found for collection: " + collectionName);
     }
 
-    String coreUrl =
-        getCoreUrl(collectionName, origCorename, clusterState, activeSlices, 
byCoreName, true);
+    String coreUrl = getCoreUrl(origCorename, clusterState, activeSlices, 
byCoreName, true);
 
     if (coreUrl == null) {
-      coreUrl =
-          getCoreUrl(collectionName, origCorename, clusterState, activeSlices, 
byCoreName, false);
+      coreUrl = getCoreUrl(origCorename, clusterState, activeSlices, 
byCoreName, false);
     }
 
     return coreUrl;
   }
 
   private String getCoreUrl(
-      String collectionName,
       String origCorename,
       ClusterState clusterState,
-      List<Slice> slices,
+      Collection<Slice> slices,
       boolean byCoreName,
       boolean activeReplicas) {
     String coreUrl;
     Set<String> liveNodes = clusterState.getLiveNodes();
 
-    List<Slice> shuffledSlices;
-    if (slices.size() < 2) {
-      shuffledSlices = slices;
-    } else {
-      shuffledSlices = new ArrayList<>(slices);
-      Collections.shuffle(shuffledSlices, Utils.RANDOM);
-    }
+    Iterator<Slice> shuffledSlices = new RandomIterator<>(Utils.RANDOM, 
slices);

Review Comment:
   I was wondering why we need to shuffle if we look for a specific core by its 
name. But I see that the byCoreName parameter is always false (byCoreName is 
now always false).
   So the code wants to find any active replica of any shard in a specific 
collection, and then return a url with replica.getBaseUrl() + "/" + 
origCoreName. Do I understand correctly? Is it the intended behavior?



-- 
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]

Reply via email to