CaoManhDat 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_r380999688
##########
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
Review comment:
I think we should get rid of this part for this issue. And open another one
if you have idea or case to support this.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]