sigram commented on a change in pull request #2199: URL: https://github.com/apache/lucene-solr/pull/2199#discussion_r560928329
########## File path: solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java ########## @@ -238,11 +247,87 @@ public PlacementPlan computePlacement(Cluster cluster, PlacementRequest request, // failure. Current code does fail if placement is impossible (constraint is at most one replica of a shard on any node). for (Replica.ReplicaType replicaType : Replica.ReplicaType.values()) { makePlacementDecisions(solrCollection, shardName, availabilityZones, replicaType, request.getCountReplicasToCreate(replicaType), - attrValues, replicaTypeToNodes, nodesWithReplicas, coresOnNodes, placementPlanFactory, replicaPlacements); + attrValues, replicaTypeToNodes, nodesWithReplicas, coresOnNodes, placementContext.getPlacementPlanFactory(), replicaPlacements); } } - return placementPlanFactory.createPlacementPlan(request, replicaPlacements); + return placementContext.getPlacementPlanFactory().createPlacementPlan(request, replicaPlacements); + } + + @Override + public void verifyAllowedModification(ModificationRequest modificationRequest, PlacementContext placementContext) throws PlacementModificationException, InterruptedException { + if (modificationRequest instanceof DeleteShardsRequest) { + throw new UnsupportedOperationException("not implemented yet"); + } else if (!(modificationRequest instanceof DeleteReplicasRequest)) { + throw new UnsupportedOperationException("unsupported request type " + modificationRequest.getClass().getName()); + } + DeleteReplicasRequest request = (DeleteReplicasRequest) modificationRequest; + SolrCollection secondaryCollection = request.getCollection(); + if (!withCollections.values().contains(secondaryCollection.getName())) { + return; + } + Map<Node, Map<String, AtomicInteger>> secondaryNodeShardReplicas = new HashMap<>(); + secondaryCollection.shards().forEach(shard -> + shard.replicas().forEach(replica -> { + secondaryNodeShardReplicas.computeIfAbsent(replica.getNode(), n -> new HashMap<>()) + .computeIfAbsent(replica.getShard().getShardName(), s -> new AtomicInteger()) + .incrementAndGet(); + })); + + // find the colocated-with collections + Cluster cluster = placementContext.getCluster(); + Set<SolrCollection> colocatedCollections = new HashSet<>(); + AtomicReference<IOException> exc = new AtomicReference<>(); Review comment: Fixed. ---------------------------------------------------------------- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org