janhoy commented on code in PR #2503:
URL: https://github.com/apache/solr/pull/2503#discussion_r3687229200


##########
solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java:
##########
@@ -305,6 +312,69 @@ public BalancePlan computeBalancing(
         .createBalancePlan(balanceRequest, replicaMovements);
   }
 
+  /**
+   * Move replicas that share a node with another replica of the same shard to 
other nodes, since
+   * multiple replicas of the same shard on one node give neither availability 
nor capacity
+   * benefits. Placement will never create such a state, per the default {@link
+   * WeightedNode#canAddReplica(Replica)}, but users can, e.g. by adding a 
replica to an explicit
+   * node. Each duplicate replica is moved to the accepting node with the 
lowest projected weight
+   * with the replica added, like {@link #computePlacements(Collection, 
PlacementContext)} does.
+   */
+  private static void moveDuplicateShardReplicas(
+      Collection<WeightedNode> weightedNodes, Map<Replica, Node> 
replicaMovements) {
+    List<WeightedNode> sourceNodes = new ArrayList<>(weightedNodes);
+    sourceNodes.sort(Comparator.comparing(node -> node.getNode().getName()));
+    for (WeightedNode sourceNode : sourceNodes) {
+      Map<String, List<Replica>> replicasPerShard =
+          sourceNode.getAllReplicasOnNode().stream()
+              .collect(
+                  Collectors.groupingBy(
+                      replica ->
+                          replica.getShard().getCollection().getName()
+                              + "%"
+                              + replica.getShard().getShardName()));

Review Comment:
   Done. Now using it only in this location, but I'll make another PR after 
this one to use the new method also to simplify `AffinityPlacementFactory` with 
the same method.



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