anshumg commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA 
API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r367158755
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
 ##########
 @@ -164,21 +168,31 @@ void deleteReplicaBasedOnCount(ClusterState clusterState,
   /**
    * Pick replicas to be deleted. Avoid picking the leader.
    */
-  private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, 
String collectionName, int count) {
-    validateReplicaAvailability(slice, shard, collectionName, count);
+  private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, 
String collectionName, int count, Replica.Type type) {
+    validateReplicaAvailability(slice, shard, collectionName, count, type);
     Collection<Replica> allReplicas = slice.getReplicas();
     Set<String> replicasToBeRemoved = new HashSet<String>();
     Replica leader = slice.getLeader();
-    for (Replica replica: allReplicas) {
+    for (Replica replica : allReplicas) {
       if (count == 0) {
         break;
       }
       //Try avoiding to pick up the leader to minimize activity on the cluster.
       if (leader.getCoreName().equals(replica.getCoreName())) {
         continue;
       }
+      // if type is not null then only verify 
+      if (type != null && !replica.getType().equals(type)) {
+        continue;
+      }
       replicasToBeRemoved.add(replica.getName());
-      count --;
+      count--;
+    }
+    // pick the leader if no options left when type is passed
+    if (count == 1) {
 
 Review comment:
   This is more complicated in my opinion than it looks. 
   You don't want to delete the only remaining replica that can be the leader. 
I'll take a better look at this tonight.

----------------------------------------------------------------
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: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to