diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/SettingsUpdater.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/SettingsUpdater.java
index a6b61844a1e..f5020a46b37 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/SettingsUpdater.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/SettingsUpdater.java
@@ -24,7 +24,6 @@ import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.ClusterSettings;
-import org.elasticsearch.common.settings.ClusterSettingsService;
import org.elasticsearch.common.settings.Settings;
import java.util.HashSet;
@@ -40,12 +39,10 @@ import static org.elasticsearch.cluster.ClusterState.builder;
final class SettingsUpdater {
final Settings.Builder transientUpdates = Settings.settingsBuilder();
final Settings.Builder persistentUpdates = Settings.settingsBuilder();
- private final ClusterSettings dynamicSettings;
- private final ClusterSettingsService clusterSettingsService;
+ private final ClusterSettings clusterSettings;
- SettingsUpdater(ClusterSettingsService clusterSettingsService) {
- this.dynamicSettings = clusterSettingsService.getClusterSettings();
- this.clusterSettingsService = clusterSettingsService;
+ SettingsUpdater(ClusterSettings clusterSettings) {
+ this.clusterSettings = clusterSettings;
}
synchronized Settings getTransientUpdates() {
@@ -85,7 +82,7 @@ final class SettingsUpdater {
Settings settings = build.metaData().settings();
// now we try to apply things and if they are invalid we fail
// this dryRun will validate & parse settings but won't actually apply them.
- clusterSettingsService.dryRun(settings);
+ clusterSettings.dryRun(settings);
return build;
}
@@ -96,7 +93,7 @@ final class SettingsUpdater {
for (Map.Entry
null
if the setting can not be found.
+ */
+ public Setting get(String key) {
+ Setting> setting = keySettings.get(key);
+ if (setting == null) {
+ for (Map.Entrytrue
if the setting for the given key is dynamically updateable. Otherwise false
.
+ */
+ public boolean hasDynamicSetting(String key) {
+ final Setting setting = get(key);
+ return setting != null && setting.isDynamic();
+ }
+
+ /**
+ * Returns a settings object that contains all clustersettings that are not
+ * already set in the given source. The diff contains either the default value for each
+ * setting or the settings value in the given default settings.
+ */
+ public Settings diff(Settings source, Settings defaultSettings) {
+ Settings.Builder builder = Settings.builder();
+ for (Setting> setting : keySettings.values()) {
+ if (setting.exists(source) == false) {
+ builder.put(setting.getKey(), setting.getRaw(defaultSettings));
+ }
+ }
+ return builder.build();
+ }
+
}
diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index 7c5da7c5074..bf9c24dad8d 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -26,8 +26,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
import org.elasticsearch.cluster.routing.allocation.decider.*;
import org.elasticsearch.cluster.service.InternalClusterService;
-import org.elasticsearch.common.settings.Setting;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
@@ -44,51 +42,10 @@ import java.util.*;
/**
* Encapsulates all valid cluster level settings.
*/
-public final class ClusterSettings {
+public final class ClusterSettings extends AbstractScopedSettings {
- private final Mapnull
if the setting can not be found.
- */
- public Setting get(String key) {
- Setting> setting = keySettings.get(key);
- if (setting == null) {
- for (Map.Entrytrue
if the setting for the given key is dynamically updateable. Otherwise false
.
- */
- public boolean hasDynamicSetting(String key) {
- final Setting setting = get(key);
- return setting != null && setting.isDynamic();
+ public ClusterSettings(Settings settings, Set