|
7 | 7 | package org.elasticsearch.xpack.deprecation; |
8 | 8 |
|
9 | 9 | import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; |
| 10 | +import org.elasticsearch.common.settings.Setting; |
10 | 11 | import org.elasticsearch.common.settings.Settings; |
11 | 12 | import org.elasticsearch.common.util.concurrent.EsExecutors; |
| 13 | +import org.elasticsearch.env.Environment; |
12 | 14 | import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; |
13 | 15 |
|
14 | 16 | import java.util.Locale; |
15 | 17 |
|
16 | 18 | class NodeDeprecationChecks { |
17 | 19 |
|
| 20 | + static DeprecationIssue checkPidfile(final Settings settings, final PluginsAndModules pluginsAndModules) { |
| 21 | + return checkDeprecatedSetting( |
| 22 | + settings, |
| 23 | + pluginsAndModules, |
| 24 | + Environment.PIDFILE_SETTING, |
| 25 | + Environment.NODE_PIDFILE_SETTING, |
| 26 | + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking-changes-7.4.html#deprecate-pidfile"); |
| 27 | + } |
| 28 | + |
18 | 29 | static DeprecationIssue checkProcessors(final Settings settings , final PluginsAndModules pluginsAndModules) { |
19 | | - if (EsExecutors.PROCESSORS_SETTING.exists(settings) == false) { |
| 30 | + return checkDeprecatedSetting( |
| 31 | + settings, |
| 32 | + pluginsAndModules, |
| 33 | + EsExecutors.PROCESSORS_SETTING, |
| 34 | + EsExecutors.NODE_PROCESSORS_SETTING, |
| 35 | + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking-changes-7.4.html#deprecate-processors"); |
| 36 | + } |
| 37 | + |
| 38 | + private static DeprecationIssue checkDeprecatedSetting( |
| 39 | + final Settings settings, |
| 40 | + final PluginsAndModules pluginsAndModules, |
| 41 | + final Setting<?> deprecatedSetting, |
| 42 | + final Setting<?> replacementSetting, |
| 43 | + final String url) { |
| 44 | + assert deprecatedSetting.isDeprecated() : deprecatedSetting; |
| 45 | + if (deprecatedSetting.exists(settings) == false) { |
20 | 46 | return null; |
21 | 47 | } |
| 48 | + final String deprecatedSettingKey = deprecatedSetting.getKey(); |
| 49 | + final String replacementSettingKey = replacementSetting.getKey(); |
| 50 | + final String value = deprecatedSetting.get(settings).toString(); |
22 | 51 | final String message = String.format( |
23 | 52 | Locale.ROOT, |
24 | 53 | "setting [%s] is deprecated in favor of setting [%s]", |
25 | | - EsExecutors.PROCESSORS_SETTING.getKey(), |
26 | | - EsExecutors.NODE_PROCESSORS_SETTING.getKey()); |
27 | | - final String url = |
28 | | - "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking-changes-7.4.html#deprecate-processors"; |
| 54 | + deprecatedSettingKey, |
| 55 | + replacementSettingKey); |
29 | 56 | final String details = String.format( |
30 | 57 | Locale.ROOT, |
31 | | - "the setting [%s] is currently set to [%d], instead set [%s] to [%d]", |
32 | | - EsExecutors.PROCESSORS_SETTING.getKey(), |
33 | | - EsExecutors.PROCESSORS_SETTING.get(settings), |
34 | | - EsExecutors.NODE_PROCESSORS_SETTING.getKey(), |
35 | | - EsExecutors.PROCESSORS_SETTING.get(settings)); |
| 58 | + "the setting [%s] is currently set to [%s], instead set [%s] to [%s]", |
| 59 | + deprecatedSettingKey, |
| 60 | + value, |
| 61 | + replacementSettingKey, |
| 62 | + value); |
36 | 63 | return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details); |
37 | 64 | } |
38 | 65 |
|
|
0 commit comments