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.
This commit is contained in:
Jason Tedor 2020-03-12 14:32:41 -04:00 committed by GitHub
parent 3972cbeba9
commit 5b08ea84c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 1 deletions

View File

@ -66,6 +66,7 @@ do this. The behavior is now the same for both field types like documented in
<<range-query-date-math-rounding>>. <<range-query-date-math-rounding>>.
[float] [float]
[[deprecate-listener-thread-pool]]
==== `thread_pool.listener.size` and `thread_pool.listener.queue_size` have been deprecated ==== `thread_pool.listener.size` and `thread_pool.listener.queue_size` have been deprecated
The listener thread pool is no longer used internally by Elasticsearch. The listener thread pool is no longer used internally by Elasticsearch.

View File

@ -45,7 +45,9 @@ public class DeprecationChecks {
NodeDeprecationChecks::checkPidfile, NodeDeprecationChecks::checkPidfile,
NodeDeprecationChecks::checkProcessors, NodeDeprecationChecks::checkProcessors,
NodeDeprecationChecks::checkMissingRealmOrders, NodeDeprecationChecks::checkMissingRealmOrders,
NodeDeprecationChecks::checkUniqueRealmOrders NodeDeprecationChecks::checkUniqueRealmOrders,
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerQueueSize(settings),
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerSize(settings)
)); ));
static List<Function<IndexMetaData, DeprecationIssue>> INDEX_SETTINGS_CHECKS = static List<Function<IndexMetaData, DeprecationIssue>> INDEX_SETTINGS_CHECKS =

View File

@ -11,12 +11,14 @@ import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.threadpool.FixedExecutorBuilder;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
import org.elasticsearch.xpack.core.security.authc.RealmSettings; import org.elasticsearch.xpack.core.security.authc.RealmSettings;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; 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<Setting<?>> listenerSettings = builder.getRegisteredSettings();
final Optional<Setting<?>> 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( private static DeprecationIssue checkDeprecatedSetting(
final Settings settings, final Settings settings,
final PluginsAndModules pluginsAndModules, final PluginsAndModules pluginsAndModules,

View File

@ -146,6 +146,36 @@ public class NodeDeprecationChecksTests extends ESTestCase {
assertEquals(0, deprecationIssues.size()); 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<DeprecationIssue> 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<DeprecationIssue> 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() { public void testRemovedSettingNotSet() {
final Settings settings = Settings.EMPTY; final Settings settings = Settings.EMPTY;
final Setting<?> removedSetting = Setting.simpleString("node.removed_setting"); final Setting<?> removedSetting = Setting.simpleString("node.removed_setting");