Skip to content

Commit 5b08ea8

Browse files
authored
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.
1 parent 3972cbe commit 5b08ea8

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

docs/reference/migration/migrate_7_7.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ do this. The behavior is now the same for both field types like documented in
6666
<<range-query-date-math-rounding>>.
6767

6868
[float]
69+
[[deprecate-listener-thread-pool]]
6970
==== `thread_pool.listener.size` and `thread_pool.listener.queue_size` have been deprecated
7071

7172
The listener thread pool is no longer used internally by Elasticsearch.

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ private DeprecationChecks() {
4545
NodeDeprecationChecks::checkPidfile,
4646
NodeDeprecationChecks::checkProcessors,
4747
NodeDeprecationChecks::checkMissingRealmOrders,
48-
NodeDeprecationChecks::checkUniqueRealmOrders
48+
NodeDeprecationChecks::checkUniqueRealmOrders,
49+
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerQueueSize(settings),
50+
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerSize(settings)
4951
));
5052

5153
static List<Function<IndexMetaData, DeprecationIssue>> INDEX_SETTINGS_CHECKS =

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import org.elasticsearch.common.settings.Settings;
1212
import org.elasticsearch.common.util.concurrent.EsExecutors;
1313
import org.elasticsearch.env.Environment;
14+
import org.elasticsearch.threadpool.FixedExecutorBuilder;
1415
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1516
import org.elasticsearch.xpack.core.security.authc.RealmSettings;
1617

1718
import java.util.List;
1819
import java.util.Locale;
1920
import java.util.Map;
21+
import java.util.Optional;
2022
import java.util.Set;
2123
import java.util.stream.Collectors;
2224

@@ -96,6 +98,25 @@ static DeprecationIssue checkUniqueRealmOrders(final Settings settings, final Pl
9698
);
9799
}
98100

101+
static DeprecationIssue checkThreadPoolListenerQueueSize(final Settings settings) {
102+
return checkThreadPoolListenerSetting("thread_pool.listener.queue_size", settings);
103+
}
104+
105+
static DeprecationIssue checkThreadPoolListenerSize(final Settings settings) {
106+
return checkThreadPoolListenerSetting("thread_pool.listener.size", settings);
107+
}
108+
109+
private static DeprecationIssue checkThreadPoolListenerSetting(final String name, final Settings settings) {
110+
final FixedExecutorBuilder builder = new FixedExecutorBuilder(settings, "listener", 1, -1, "thread_pool.listener", true);
111+
final List<Setting<?>> listenerSettings = builder.getRegisteredSettings();
112+
final Optional<Setting<?>> setting = listenerSettings.stream().filter(s -> s.getKey().equals(name)).findFirst();
113+
assert setting.isPresent();
114+
return checkRemovedSetting(
115+
settings,
116+
setting.get(),
117+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool");
118+
}
119+
99120
private static DeprecationIssue checkDeprecatedSetting(
100121
final Settings settings,
101122
final PluginsAndModules pluginsAndModules,

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ public void testCorrectRealmOrders() {
146146
assertEquals(0, deprecationIssues.size());
147147
}
148148

149+
public void testThreadPoolListenerQueueSize() {
150+
final int size = randomIntBetween(1, 4);
151+
final Settings settings = Settings.builder().put("thread_pool.listener.queue_size", size).build();
152+
final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList());
153+
final List<DeprecationIssue> issues =
154+
DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules));
155+
final DeprecationIssue expected = new DeprecationIssue(
156+
DeprecationIssue.Level.CRITICAL,
157+
"setting [thread_pool.listener.queue_size] is deprecated and will be removed in the next major version",
158+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool",
159+
"the setting [thread_pool.listener.queue_size] is currently set to [" + size + "], remove this setting");
160+
assertThat(issues, contains(expected));
161+
assertSettingDeprecationsAndWarnings(new String[]{"thread_pool.listener.queue_size"});
162+
}
163+
164+
public void testThreadPoolListenerSize() {
165+
final int size = randomIntBetween(1, 4);
166+
final Settings settings = Settings.builder().put("thread_pool.listener.size", size).build();
167+
final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList());
168+
final List<DeprecationIssue> issues =
169+
DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules));
170+
final DeprecationIssue expected = new DeprecationIssue(
171+
DeprecationIssue.Level.CRITICAL,
172+
"setting [thread_pool.listener.size] is deprecated and will be removed in the next major version",
173+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.7.html#deprecate-listener-thread-pool",
174+
"the setting [thread_pool.listener.size] is currently set to [" + size + "], remove this setting");
175+
assertThat(issues, contains(expected));
176+
assertSettingDeprecationsAndWarnings(new String[]{"thread_pool.listener.size"});
177+
}
178+
149179
public void testRemovedSettingNotSet() {
150180
final Settings settings = Settings.EMPTY;
151181
final Setting<?> removedSetting = Setting.simpleString("node.removed_setting");

0 commit comments

Comments
 (0)