Skip to content

Apache Lucene open-source search software

SOLR-12648: Use the information whether custom preferences were specified in the CloudUtil.usePolicyFramework method instead of comparing directly against default preferences. Comparing against default preferences was wrong because it ignores the case where the user explicitly added the same preferences as the default ones.

Shalin Shekhar Mangar05949a32c9a1
diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
index 26ba1b86e5a..14bebeff353 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
@@ -29,7 +29,6 @@ import java.util.Optional;
import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
-import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.ClusterState;
@@ -174,7 +173,7 @@ public class CloudUtil {
// if no autoscaling configuration exists then obviously we cannot use the policy framework
if (autoScalingConfig.getPolicy().isEmpty()) return false;
// do custom preferences exist
- if (!autoScalingConfig.getPolicy().getClusterPreferences().equals(Policy.DEFAULT_PREFERENCES)) return true;
+ if (!autoScalingConfig.getPolicy().isEmptyPreferences()) return true;
// does a cluster policy exist
if (!autoScalingConfig.getPolicy().getClusterPolicy().isEmpty()) return true;
// finally we check if the current collection has a policy
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
index 78043dfb152..cfe9455fb9b 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
@@ -478,6 +478,13 @@ public class Policy implements MapWriter {
return empty;
}
+ /**
+ * @return true if no preferences were specified by the user, false otherwise
+ */
+ public boolean isEmptyPreferences() {
+ return emptyPreferences;
+ }
+
/*This stores the logical state of the system, given a policy and
* a cluster state.
*