You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/11/14 00:16:53 UTC

[lucene-solr] 03/03: @1188 More shuffling.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit cbdbe8d07ea8ff5772ca26ac136c6c46a6f22df3
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Fri Nov 13 18:08:54 2020 -0600

    @1188 More shuffling.
---
 .../org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java     | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index 6be6a15..eeab56c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -1172,7 +1172,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
         if (col == null) {
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);
         }
-        Collection<Slice> routeSlices = col.getRouter().getSearchSlices(shardKeys, reqParams , col);
+        List<Slice> routeSlices = new ArrayList<>(col.getRouter().getSearchSlices(shardKeys, reqParams , col));
+        Collections.shuffle(routeSlices);
         ClientUtils.addSlices(slices, collectionName, routeSlices, true);
       }
 
@@ -1181,7 +1182,9 @@ public abstract class BaseCloudSolrClient extends SolrClient {
       List<Replica> replicas = new ArrayList<>();
       for (Slice slice : slices.values()) {
         Replica leader = slice.getLeader();
-        for (Replica replica : slice.getReplicas()) {
+        ArrayList<Replica> replicaList = new ArrayList<>(slice.getReplicas());
+        Collections.shuffle(replicaList);
+        for (Replica replica : replicaList) {
           String node = replica.getNodeName();
           if (!liveNodes.contains(node) // Must be a live node to continue
               || replica.getState() != Replica.State.ACTIVE) // Must be an ACTIVE replica to continue