shalinmangar commented on a change in pull request #1417: SOLR-12847:
Auto-create a policy rule that corresponds to maxShardsPerNode
URL: https://github.com/apache/lucene-solr/pull/1417#discussion_r406736277
##########
File path:
solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
##########
@@ -407,14 +466,81 @@ public void call(ClusterState clusterState, ZkNodeProps
message, NamedList resul
.assignPullReplicas(numPullReplicas)
.onNodes(nodeList)
.build();
- Assign.AssignStrategyFactory assignStrategyFactory = new
Assign.AssignStrategyFactory(cloudManager);
+ // if Strategy.POLICY is in use AND maxShardsPerNode was specified then
for back-compat it needs to
+ // be translated into a rule (see SOLR-12847).
+ // Modify the autoscaling rules as needed BEFORE actually calling
assign, setting configToRestore as
+ // a side-effect to restore the original config if the creation fails
+ if ((strategy == Assign.AssignStrategyFactory.Strategy.POLICY) &&
+ (maxReplicasPerNode != null && maxReplicasPerNode !=
Integer.MAX_VALUE)) {
+ maybeAddMaxReplicasRule(cloudManager, maxReplicasPerNode,
docCollection, configToRestore);
Review comment:
I would have preferred to do this outside of this method instead of adding a
side effect here. That way the addition of the clause as well as its cleanup
can be in one place.
----------------------------------------------------------------
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]