From 69e95deb47aff9a3827deb0761b48df3b7715bba Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 14 Jan 2016 16:28:05 +0100 Subject: [PATCH] convert index.ttl.disable_purge --- .../elasticsearch/cluster/ClusterModule.java | 1 - .../elasticsearch/index/IndexSettings.java | 20 ++++++++++++++++-- .../indices/ttl/IndicesTTLService.java | 4 +--- .../index/IndexSettingsTests.java | 21 +++++++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterModule.java b/core/src/main/java/org/elasticsearch/cluster/ClusterModule.java index 4408e361ae5..fa6ddd35039 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterModule.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterModule.java @@ -138,7 +138,6 @@ public class ClusterModule extends AbstractModule { registerIndexDynamicSetting(IndexMetaData.SETTING_BLOCKS_METADATA, Validator.EMPTY); registerIndexDynamicSetting(IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, Validator.EMPTY); registerIndexDynamicSetting(IndexMetaData.SETTING_PRIORITY, Validator.NON_NEGATIVE_INTEGER); - registerIndexDynamicSetting(IndicesTTLService.INDEX_TTL_DISABLE_PURGE, Validator.EMPTY); registerIndexDynamicSetting(PrimaryShardAllocator.INDEX_RECOVERY_INITIAL_SHARDS, Validator.EMPTY); registerIndexDynamicSetting(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_WARN, Validator.TIME); registerIndexDynamicSetting(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_INFO, Validator.TIME); diff --git a/core/src/main/java/org/elasticsearch/index/IndexSettings.java b/core/src/main/java/org/elasticsearch/index/IndexSettings.java index 603a6241bde..1eddaab26f1 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexSettings.java +++ b/core/src/main/java/org/elasticsearch/index/IndexSettings.java @@ -65,6 +65,8 @@ public final class IndexSettings { public static final String INDEX_TRANSLOG_SYNC_INTERVAL = "index.translog.sync_interval"; public static final Setting INDEX_TRANSLOG_DURABILITY_SETTING = new Setting<>("index.translog.durability", Translog.Durability.REQUEST.name(), (value) -> Translog.Durability.valueOf(value.toUpperCase(Locale.ROOT)), true, Setting.Scope.INDEX); public static final Setting INDEX_WARMER_ENABLED_SETTING = Setting.boolSetting("index.warmer.enabled", true, true, Setting.Scope.INDEX); + public static final Setting INDEX_TTL_DISABLE_PURGE_SETTING = Setting.boolSetting("index.ttl.disable_purge", false, true, Setting.Scope.INDEX); + /** * Index setting describing the maximum value of from + size on a query. * The Default maximum value of from + size on a query is 10,000. This was chosen as @@ -114,8 +116,11 @@ public final class IndexSettings { private long gcDeletesInMillis = DEFAULT_GC_DELETES.millis(); private volatile boolean warmerEnabled; private volatile int maxResultWindow; + private volatile boolean TTLPurgeDisabled; + public static Set> BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( + INDEX_TTL_DISABLE_PURGE_SETTING, IndexStore.INDEX_STORE_THROTTLE_TYPE_SETTING, IndexStore.INDEX_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, MergeSchedulerConfig.AUTO_THROTTLE_SETTING, @@ -133,8 +138,6 @@ public final class IndexSettings { EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING ))); - - /** * Returns the default search field for this index. */ @@ -222,6 +225,8 @@ public final class IndexSettings { scopedSettings.addSettingsUpdateConsumer(INDEX_WARMER_ENABLED_SETTING, this::setEnableWarmer); maxResultWindow = scopedSettings.get(MAX_RESULT_WINDOW_SETTING); scopedSettings.addSettingsUpdateConsumer(MAX_RESULT_WINDOW_SETTING, this::setMaxResultWindow); + TTLPurgeDisabled = scopedSettings.get(INDEX_TTL_DISABLE_PURGE_SETTING); + scopedSettings.addSettingsUpdateConsumer(INDEX_TTL_DISABLE_PURGE_SETTING, this::setTTLPurgeDisabled); this.mergePolicyConfig = new MergePolicyConfig(logger, settings); assert indexNameMatcher.test(indexMetaData.getIndex()); @@ -459,6 +464,17 @@ public final class IndexSettings { 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; + } + boolean containsSetting(Setting setting) { return scopedSettings.get(setting.getKey()) != null; } diff --git a/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java index 4f48e4f7b93..e1b6f2ddbd1 100644 --- a/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java +++ b/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java @@ -68,7 +68,6 @@ import java.util.concurrent.locks.ReentrantLock; public class IndicesTTLService extends AbstractLifecycleComponent { public static final Setting INDICES_TTL_INTERVAL_SETTING = Setting.positiveTimeSetting("indices.ttl.interval", TimeValue.timeValueSeconds(60), true, Setting.Scope.CLUSTER); - public static final String INDEX_TTL_DISABLE_PURGE = "index.ttl.disable_purge"; private final ClusterService clusterService; private final IndicesService indicesService; @@ -164,8 +163,7 @@ public class IndicesTTLService extends AbstractLifecycleComponent