Skip to content

Apache Lucene open-source search software

SOLR-11051: Use disk free metric in default cluster preferences

Noble Paul2f4f8932c6d8
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1e612ad670c..bbd91f72cca 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -175,6 +175,8 @@ Other Changes
collection is deleted and re-created, the autocreated configset will be left behind and will be re-used for
the re-created collection (Ishan Chattopadhyaya, Abhishek Kumar Singh)
+* SOLR-11051: Use disk free metric in default cluster preferences (noble)
+
================== 7.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
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 4697572c741..91932eab6a8 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
@@ -70,7 +70,10 @@ public class Policy implements MapWriter {
public static final String CLUSTER_POLICY = "cluster-policy";
public static final String CLUSTER_PREFERENCES = "cluster-preferences";
public static final Set<String> GLOBAL_ONLY_TAGS = Collections.singleton("cores");
- public static final Preference DEFAULT_PREFERENCE = new Preference((Map<String, Object>) Utils.fromJSONString("{minimize : cores, precision:1}"));
+ public static final List<Preference> DEFAULT_PREFERENCES = Collections.unmodifiableList(
+ Arrays.asList(
+ new Preference((Map<String, Object>) Utils.fromJSONString("{minimize : cores, precision:1}")),
+ new Preference((Map<String, Object>) Utils.fromJSONString("{maximize : freedisk}"))));
final Map<String, List<Clause>> policies;
final List<Clause> clusterPolicy;
final List<Preference> clusterPreferences;
@@ -91,7 +94,7 @@ public class Policy implements MapWriter {
preference.next = initialClusterPreferences.get(i + 1);
}
if (initialClusterPreferences.isEmpty()) {
- initialClusterPreferences.add(DEFAULT_PREFERENCE);
+ initialClusterPreferences.addAll(DEFAULT_PREFERENCES);
}
this.clusterPreferences = Collections.unmodifiableList(initialClusterPreferences);
final SortedSet<String> paramsOfInterest = new TreeSet<>();
@@ -122,8 +125,7 @@ public class Policy implements MapWriter {
private Policy(Map<String, List<Clause>> policies, List<Clause> clusterPolicy, List<Preference> clusterPreferences) {
this.policies = policies != null ? Collections.unmodifiableMap(policies) : Collections.emptyMap();
this.clusterPolicy = clusterPolicy != null ? Collections.unmodifiableList(clusterPolicy) : Collections.emptyList();
- this.clusterPreferences = clusterPreferences != null ? Collections.unmodifiableList(clusterPreferences) :
- Collections.singletonList(DEFAULT_PREFERENCE);
+ this.clusterPreferences = clusterPreferences != null ? Collections.unmodifiableList(clusterPreferences) : DEFAULT_PREFERENCES;
this.params = Collections.unmodifiableList(buildParams(this.clusterPreferences, this.clusterPolicy, this.policies));
perReplicaAttributes = readPerReplicaAttrs();
}