Apache Solr open-source search software
SOLR-15209: Rename the LegacyPlacementPolicy to the SimplePlacementPolicy
Houston Putmanda7ce14ee9da
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ac19b1acccb..5b739c032ac 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -229,7 +229,7 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)* SOLR-14608: Faster sorting for the /export handler (Joel Bernstein)-* SOLR-15209: The old LegacyAssignStrategy has been refactored into the LegacyPlacementPlugin. This is still the default+* SOLR-15209: The old LegacyAssignStrategy has been refactored into the SimplePlacementPlugin. This is still the defaultplacement policy for Solr. (Houston Putman, Ilan Ginzburg)Builddiff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.javaindex 02a573ca667..f20726d6f13 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java@@ -30,7 +30,7 @@ import org.apache.solr.client.solrj.cloud.BadVersionException;import org.apache.solr.client.solrj.cloud.VersionedData;import org.apache.solr.cluster.placement.PlacementPlugin;import org.apache.solr.cluster.placement.impl.PlacementPluginAssignStrategy;-import org.apache.solr.cluster.placement.plugins.LegacyPlacementFactory;+import org.apache.solr.cluster.placement.plugins.SimplePlacementFactory;import org.apache.solr.common.SolrException;import org.apache.solr.common.cloud.ClusterState;import org.apache.solr.common.cloud.DocCollection;@@ -463,7 +463,7 @@ public class Assign {/*** Creates the appropriate instance of {@link AssignStrategy} based on how the cluster and/or individual collections are* configured.- * <p>If {@link PlacementPlugin} instance is null this call will return a strategy from {@link LegacyPlacementFactory}, otherwise+ * <p>If {@link PlacementPlugin} instance is null this call will return a strategy from {@link SimplePlacementFactory}, otherwise* {@link PlacementPluginAssignStrategy} will be used.</p>*/public static AssignStrategy createAssignStrategy(CoreContainer coreContainer) {@@ -472,7 +472,7 @@ public class Assign {if (placementPlugin == null) {// Otherwise use the default// TODO: Replace this with a better options, such as the AffinityPlacementFactory- placementPlugin = (new LegacyPlacementFactory()).createPluginInstance();+ placementPlugin = (new SimplePlacementFactory()).createPluginInstance();}return new PlacementPluginAssignStrategy(placementPlugin);}diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPluginFactory.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPluginFactory.javaindex 138aab27e4f..ccd3f9f34e9 100644--- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPluginFactory.java+++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPluginFactory.java@@ -18,7 +18,7 @@package org.apache.solr.cluster.placement;import org.apache.solr.api.ConfigurablePlugin;-import org.apache.solr.cluster.placement.plugins.LegacyPlacementFactory;+import org.apache.solr.cluster.placement.plugins.SimplePlacementFactory;/*** Factory implemented by client code and configured in container plugins@@ -40,7 +40,7 @@ public interface PlacementPluginFactory<T extends PlacementPluginConfig> extends* instances of a plugin can be used in parallel (for example if configuration has to change, but plugin instances with* the previous configuration are still being used).* <p>If this method returns null then a simple default assignment strategy will be used- * (see {@link LegacyPlacementFactory}).</p>+ * (see {@link SimplePlacementFactory}).</p>*/PlacementPlugin createPluginInstance();diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/LegacyPlacementFactory.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/SimplePlacementFactory.javasimilarity index 96%rename from solr/core/src/java/org/apache/solr/cluster/placement/plugins/LegacyPlacementFactory.javarename to solr/core/src/java/org/apache/solr/cluster/placement/plugins/SimplePlacementFactory.javaindex c14a737d8d3..420d3cb7e8e 100644--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/LegacyPlacementFactory.java+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/SimplePlacementFactory.java@@ -40,19 +40,19 @@ import java.util.Set;import java.util.stream.Collectors;/**- * <p>Factory for creating {@link LegacyPlacementPlugin}, a placement plugin implementing the logic from the old <code>LegacyAssignStrategy</code>.+ * <p>Factory for creating {@link SimplePlacementPlugin}, a placement plugin implementing the logic from the old <code>LegacyAssignStrategy</code>.* This chooses nodes with the fewest cores (especially cores of the same collection).</p>** <p>See {@link AffinityPlacementFactory} for a more realistic example and documentation.</p>*/-public class LegacyPlacementFactory implements PlacementPluginFactory<PlacementPluginFactory.NoConfig> {+public class SimplePlacementFactory implements PlacementPluginFactory<PlacementPluginFactory.NoConfig> {@Overridepublic PlacementPlugin createPluginInstance() {- return new LegacyPlacementPlugin();+ return new SimplePlacementPlugin();}- public static class LegacyPlacementPlugin implements PlacementPlugin {+ public static class SimplePlacementPlugin implements PlacementPlugin {@Overridepublic List<PlacementPlan> computePlacements(Collection<PlacementRequest> requests, PlacementContext placementContext) throws PlacementException {List<PlacementPlan> placementPlans = new ArrayList<>(requests.size());diff --git a/solr/solr-ref-guide/src/replica-placement-plugins.adoc b/solr/solr-ref-guide/src/replica-placement-plugins.adocindex d1ea48c2e59..eca81eec19f 100644--- a/solr/solr-ref-guide/src/replica-placement-plugins.adoc+++ b/solr/solr-ref-guide/src/replica-placement-plugins.adoc@@ -34,7 +34,7 @@ The configuration entry may also contain a `config` element if the plugin implem== Placement Plugins Included with SolrThe following placement plugins are available out-of-the-box in Solr 9.0.-If no placement plugin is defined, Solr will default to using the <<#legacyplacementfactory,LegacyPlacementPlugin>>+If no placement plugin is defined, Solr will default to using the <<#simpleplacementfactory,SimplePlacementPlugin>>.In order to use a plugin its configuration must be added using the `/cluster/plugin` API.For example, in order to use the `AffinityPlacementFactory` plugin the following command should be executed:@@ -66,16 +66,18 @@ Similarly, the configuration can be updated or removed.NOTE: Placement plugin configuration MUST use the predefined name `.placement-plugin`.There can be only one (or none) placement configuration defined.-=== LegacyPlacementFactory-By default Solr 9.0 uses a legacy method for replica placements, the `LegacyPlacementFactory`.+=== SimplePlacementFactory+By default Solr 9.0 uses a legacy method for replica placements, the `SimplePlacementFactory`.This method is used whenever the placement plugin configuration is missing or invalid.-Legacy placement simply assigns new replicas to live nodes in a round-robin fashion: first it prepares a sorted list of nodes with the smallest number of existing replicas, especially of the collection.+Simple placement simply assigns new replicas to live nodes in a round-robin fashion: first it prepares a sorted list of nodes with the smallest number of existing replicas, especially of the collection.Then for each shard in the request it adds the replicas to consecutive nodes in this order, wrapping around to the first node if the number of replicas is larger than the number of nodes.This placement strategy doesn't ensure that no more than 1 replica of a shard is placed on the same node.Also, the round-robin assignment only roughly approximates an even spread of replicas across the nodes.+NOTE: This was the default non-autoscaling behavior prior to 9.0, at the time called the LegacyAssignStrategy.+=== RandomPlacementFactoryThis plugin creates random placements, while preventing two replicas of the same shard from being placed on the same node.If there are too few nodes to satisfy these constraints an exception is thrown, and the request is rejected.