From 5b08ea84c9ee3008e69df0260f9cb1fb50bbc911 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 12 Mar 2020 14:32:41 -0400 Subject: [PATCH] Add deprecation check for listener thread pool (#53438) This commit adds a deprecation check for the listener thread pool settings as these will be removed in 8.0.0. --- docs/reference/migration/migrate_7_7.asciidoc | 1 + .../xpack/deprecation/DeprecationChecks.java | 4 ++- .../deprecation/NodeDeprecationChecks.java | 21 +++++++++++++ .../NodeDeprecationChecksTests.java | 30 +++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/reference/migration/migrate_7_7.asciidoc b/docs/reference/migration/migrate_7_7.asciidoc index 9aa971f7dd5..a4f4de62a05 100644 --- a/docs/reference/migration/migrate_7_7.asciidoc +++ b/docs/reference/migration/migrate_7_7.asciidoc @@ -66,6 +66,7 @@ do this. The behavior is now the same for both field types like documented in <>. [float] +[[deprecate-listener-thread-pool]] ==== `thread_pool.listener.size` and `thread_pool.listener.queue_size` have been deprecated The listener thread pool is no longer used internally by Elasticsearch. diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java index 46a74d8ba48..bc5ea2558c3 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java @@ -45,7 +45,9 @@ public class DeprecationChecks { NodeDeprecationChecks::checkPidfile, NodeDeprecationChecks::checkProcessors, NodeDeprecationChecks::checkMissingRealmOrders, - NodeDeprecationChecks::checkUniqueRealmOrders + NodeDeprecationChecks::checkUniqueRealmOrders, + (settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerQueueSize(settings), + (settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerSize(settings) )); static List> INDEX_SETTINGS_CHECKS = diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 5760a7db41a..f370ab26e6d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -11,12 +11,14 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.env.Environment; +import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; import org.elasticsearch.xpack.core.security.authc.RealmSettings; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -96,6 +98,25 @@ class NodeDeprecationChecks { ); } + static DeprecationIssue checkThreadPoolListenerQueueSize(final Settings settings) { + return checkThreadPoolListenerSetting("thread_pool.listener.queue_size", settings); + } + + static DeprecationIssue checkThreadPoolListenerSize(final Settings settings) { + return checkThreadPoolListenerSetting("thread_pool.listener.size", settings); + } + + private static DeprecationIssue checkThreadPoolListenerSetting(final String name, final Settings settings) { + final FixedExecutorBuilder builder = new FixedExecutorBuilder(settings, "listener", 1, -1, "thread_pool.listener", true); + final List> listenerSettings = builder.getRegisteredSettings(); + final Optional> setting = listenerSettings.stream().filter(s -> s.getKey().equals(name)).findFirst(); + assert setting.isPresent(); + return checkRemovedSetting( + settings, + setting.get(), + "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool"); + } + private static DeprecationIssue checkDeprecatedSetting( final Settings settings, final PluginsAndModules pluginsAndModules, diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 4b5970f22e9..19b5931c8f3 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -146,6 +146,36 @@ public class NodeDeprecationChecksTests extends ESTestCase { assertEquals(0, deprecationIssues.size()); } + public void testThreadPoolListenerQueueSize() { + final int size = randomIntBetween(1, 4); + final Settings settings = Settings.builder().put("thread_pool.listener.queue_size", size).build(); + final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList()); + final List issues = + DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules)); + final DeprecationIssue expected = new DeprecationIssue( + DeprecationIssue.Level.CRITICAL, + "setting [thread_pool.listener.queue_size] is deprecated and will be removed in the next major version", + "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool", + "the setting [thread_pool.listener.queue_size] is currently set to [" + size + "], remove this setting"); + assertThat(issues, contains(expected)); + assertSettingDeprecationsAndWarnings(new String[]{"thread_pool.listener.queue_size"}); + } + + public void testThreadPoolListenerSize() { + final int size = randomIntBetween(1, 4); + final Settings settings = Settings.builder().put("thread_pool.listener.size", size).build(); + final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList()); + final List issues = + DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules)); + final DeprecationIssue expected = new DeprecationIssue( + DeprecationIssue.Level.CRITICAL, + "setting [thread_pool.listener.size] is deprecated and will be removed in the next major version", + "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool", + "the setting [thread_pool.listener.size] is currently set to [" + size + "], remove this setting"); + assertThat(issues, contains(expected)); + assertSettingDeprecationsAndWarnings(new String[]{"thread_pool.listener.size"}); + } + public void testRemovedSettingNotSet() { final Settings settings = Settings.EMPTY; final Setting removedSetting = Setting.simpleString("node.removed_setting");