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.

This commit is contained in:
Shalin Shekhar Mangar 2018-10-03 16:58:45 +05:30
parent 554ac64666
commit 05949a32c9
2 changed files with 8 additions and 2 deletions

View File

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

View File

@ -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.
*