From 6e4f504eb96041beddb9efda24be381ddd8b96e6 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sat, 14 Apr 2018 11:23:14 +0100 Subject: [PATCH] Deprecate unused index.ttl.disable_purge setting This setting does nothing. This change deprecates it, for the 6.x series, and a followup will remove it in 7.0. --- .../elasticsearch/index/IndexSettings.java | 18 ++------------- .../index/IndexSettingsTests.java | 22 +++++-------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/IndexSettings.java b/server/src/main/java/org/elasticsearch/index/IndexSettings.java index eaf92893bd5b9..9a3a5512c6c1e 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexSettings.java +++ b/server/src/main/java/org/elasticsearch/index/IndexSettings.java @@ -80,8 +80,9 @@ public final class IndexSettings { (value) -> Translog.Durability.valueOf(value.toUpperCase(Locale.ROOT)), Property.Dynamic, Property.IndexScope); public static final Setting INDEX_WARMER_ENABLED_SETTING = Setting.boolSetting("index.warmer.enabled", true, Property.Dynamic, Property.IndexScope); + @Deprecated public static final Setting INDEX_TTL_DISABLE_PURGE_SETTING = - Setting.boolSetting("index.ttl.disable_purge", false, Property.Dynamic, Property.IndexScope); + Setting.boolSetting("index.ttl.disable_purge", false, Property.Dynamic, Property.IndexScope, Property.Deprecated); public static final Setting INDEX_CHECK_ON_STARTUP = new Setting<>("index.shard.check_on_startup", "false", (s) -> { switch(s) { case "false": @@ -302,7 +303,6 @@ public final class IndexSettings { private volatile int maxScriptFields; private volatile int maxNgramDiff; private volatile int maxShingleDiff; - private volatile boolean TTLPurgeDisabled; private volatile int maxAnalyzedOffset; private volatile int maxTermsCount; @@ -410,7 +410,6 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti maxScriptFields = scopedSettings.get(MAX_SCRIPT_FIELDS_SETTING); maxNgramDiff = scopedSettings.get(MAX_NGRAM_DIFF_SETTING); maxShingleDiff = scopedSettings.get(MAX_SHINGLE_DIFF_SETTING); - TTLPurgeDisabled = scopedSettings.get(INDEX_TTL_DISABLE_PURGE_SETTING); maxRefreshListeners = scopedSettings.get(MAX_REFRESH_LISTENERS_PER_SHARD); maxSlicesPerScroll = scopedSettings.get(MAX_SLICES_PER_SCROLL); maxAnalyzedOffset = scopedSettings.get(MAX_ANALYZED_OFFSET_SETTING); @@ -436,7 +435,6 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti mergeSchedulerConfig::setMaxThreadAndMergeCount); scopedSettings.addSettingsUpdateConsumer(MergeSchedulerConfig.AUTO_THROTTLE_SETTING, mergeSchedulerConfig::setAutoThrottle); scopedSettings.addSettingsUpdateConsumer(INDEX_TRANSLOG_DURABILITY_SETTING, this::setTranslogDurability); - scopedSettings.addSettingsUpdateConsumer(INDEX_TTL_DISABLE_PURGE_SETTING, this::setTTLPurgeDisabled); scopedSettings.addSettingsUpdateConsumer(MAX_RESULT_WINDOW_SETTING, this::setMaxResultWindow); scopedSettings.addSettingsUpdateConsumer(MAX_INNER_RESULT_WINDOW_SETTING, this::setMaxInnerResultWindow); scopedSettings.addSettingsUpdateConsumer(MAX_ADJACENCY_MATRIX_FILTERS_SETTING, this::setMaxAdjacencyMatrixFilters); @@ -774,18 +772,6 @@ public MergePolicy getMergePolicy() { return mergePolicyConfig.getMergePolicy(); } - /** - * Returns true if the TTL purge is disabled for this index. Default is false - */ - public boolean isTTLPurgeDisabled() { - return TTLPurgeDisabled; - } - - private void setTTLPurgeDisabled(boolean ttlPurgeDisabled) { - this.TTLPurgeDisabled = ttlPurgeDisabled; - } - - public T getValue(Setting setting) { return scopedSettings.get(setting); } diff --git a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java index c5a8aa5bdc2b8..102f45453fd30 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java @@ -386,24 +386,12 @@ public void testGCDeletesSetting() { } public void testIsTTLPurgeDisabled() { - IndexMetaData metaData = newIndexMeta("index", Settings.builder() + final Settings settings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) - .put(IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING.getKey(), false) - .build()); - IndexSettings settings = new IndexSettings(metaData, Settings.EMPTY); - assertFalse(settings.isTTLPurgeDisabled()); - settings.updateIndexMetaData(newIndexMeta("index", Settings.builder().put(IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING.getKey(), - "true").build())); - assertTrue(settings.isTTLPurgeDisabled()); - - settings.updateIndexMetaData(newIndexMeta("index", Settings.EMPTY)); - assertFalse("reset to default", settings.isTTLPurgeDisabled()); - - metaData = newIndexMeta("index", Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) - .build()); - settings = new IndexSettings(metaData, Settings.EMPTY); - assertFalse(settings.isTTLPurgeDisabled()); + .put(IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING.getKey(), true) + .build(); + assertTrue(IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[]{IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING}); } public void testTranslogFlushSizeThreshold() {