Skip to content

Commit 5ca2c91

Browse files
committed
Clean up
1 parent 0ffc1c7 commit 5ca2c91

12 files changed

+133
-201
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import java.util.HashMap;
1919
import java.util.List;
2020
import java.util.Map;
21+
import java.util.Objects;
2122
import java.util.Set;
2223
import java.util.function.BiFunction;
2324
import java.util.stream.Collectors;
2425

2526
import static java.util.Map.entry;
2627
import static java.util.Map.ofEntries;
27-
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.filterChecks;
2828

2929
/**
3030
* Checks the data streams for deprecation warnings.
@@ -72,7 +72,10 @@ public Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
7272
Map<String, List<DeprecationIssue>> dataStreamIssues = new HashMap<>();
7373
for (String dataStreamName : dataStreamNames) {
7474
DataStream dataStream = clusterState.metadata().dataStreams().get(dataStreamName);
75-
List<DeprecationIssue> issuesForSingleDataStream = filterChecks(DATA_STREAM_CHECKS, c -> c.apply(dataStream, clusterState));
75+
List<DeprecationIssue> issuesForSingleDataStream = DATA_STREAM_CHECKS.stream()
76+
.map(c -> c.apply(dataStream, clusterState))
77+
.filter(Objects::nonNull)
78+
.toList();
7679
if (issuesForSingleDataStream.isEmpty() == false) {
7780
dataStreamIssues.put(dataStreamName, issuesForSingleDataStream);
7881
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import java.util.function.Predicate;
3434
import java.util.function.Supplier;
3535

36-
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.SKIP_DEPRECATIONS_SETTING;
36+
import static org.elasticsearch.xpack.deprecation.TransportDeprecationInfoAction.SKIP_DEPRECATIONS_SETTING;
3737
import static org.elasticsearch.xpack.deprecation.logging.DeprecationIndexingComponent.DEPRECATION_INDEXING_FLUSH_INTERVAL;
3838

3939
/**

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

Lines changed: 0 additions & 47 deletions
This file was deleted.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import java.util.HashMap;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.function.Function;
2324

24-
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.filterChecks;
2525
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_COMMON_DETAIL;
2626
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_HELP_URL;
2727
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_MESSAGE;
@@ -33,10 +33,7 @@
3333
public class IlmPolicyDeprecationChecker implements ResourceDeprecationChecker {
3434

3535
public static final String NAME = "ilm_policies";
36-
private static final List<Function<LifecyclePolicy, DeprecationIssue>> CHECKS = List.of(
37-
IlmPolicyDeprecationChecker::checkLegacyTiers,
38-
IlmPolicyDeprecationChecker::checkFrozenAction
39-
);
36+
private final List<Function<LifecyclePolicy, DeprecationIssue>> checks = List.of(this::checkLegacyTiers, this::checkFrozenAction);
4037

4138
/**
4239
* @param clusterState The cluster state provided for the checker
@@ -67,15 +64,18 @@ Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
6764
String name = entry.getKey();
6865
LifecyclePolicyMetadata policyMetadata = entry.getValue();
6966

70-
List<DeprecationIssue> issuesForSinglePolicy = filterChecks(CHECKS, c -> c.apply(policyMetadata.getPolicy()));
67+
List<DeprecationIssue> issuesForSinglePolicy = checks.stream()
68+
.map(c -> c.apply(policyMetadata.getPolicy()))
69+
.filter(Objects::nonNull)
70+
.toList();
7171
if (issuesForSinglePolicy.isEmpty() == false) {
7272
issues.put(name, issuesForSinglePolicy);
7373
}
7474
}
7575
return issues.isEmpty() ? Map.of() : issues;
7676
}
7777

78-
static DeprecationIssue checkLegacyTiers(LifecyclePolicy policy) {
78+
private DeprecationIssue checkLegacyTiers(LifecyclePolicy policy) {
7979
for (Phase phase : policy.getPhases().values()) {
8080
AllocateAction allocateAction = (AllocateAction) phase.getActions().get(AllocateAction.NAME);
8181
if (allocateAction != null) {
@@ -96,7 +96,7 @@ static DeprecationIssue checkLegacyTiers(LifecyclePolicy policy) {
9696
return null;
9797
}
9898

99-
static DeprecationIssue checkFrozenAction(LifecyclePolicy policy) {
99+
private DeprecationIssue checkFrozenAction(LifecyclePolicy policy) {
100100
for (Phase phase : policy.getPhases().values()) {
101101
if (phase.getActions().containsKey(FreezeAction.NAME)) {
102102
return new DeprecationIssue(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import java.util.List;
2626
import java.util.Locale;
2727
import java.util.Map;
28+
import java.util.Objects;
2829
import java.util.function.BiConsumer;
2930
import java.util.function.BiFunction;
3031
import java.util.function.Function;
3132
import java.util.stream.Collectors;
3233

33-
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.filterChecks;
3434
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_COMMON_DETAIL;
3535
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_HELP_URL;
3636

@@ -67,7 +67,10 @@ public Map<String, List<DeprecationIssue>> check(
6767
Map<String, List<String>> indexToTransformIds = indexToTransformIds(precomputedData.transformConfigs());
6868
for (String concreteIndex : concreteIndexNames) {
6969
IndexMetadata indexMetadata = clusterState.getMetadata().index(concreteIndex);
70-
List<DeprecationIssue> singleIndexIssues = filterChecks(checks, c -> c.apply(indexMetadata, clusterState, indexToTransformIds));
70+
List<DeprecationIssue> singleIndexIssues = checks.stream()
71+
.map(c -> c.apply(indexMetadata, clusterState, indexToTransformIds))
72+
.filter(Objects::nonNull)
73+
.toList();
7174
if (singleIndexIssues.isEmpty() == false) {
7275
indexSettingsIssues.put(concreteIndex, singleIndexIssues);
7376
}

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

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -43,62 +43,57 @@ public class NodeDeprecationChecks {
4343

4444
// Visible for testing
4545
static final List<
46-
DeprecationChecks.NodeDeprecationCheck<
47-
Settings,
48-
PluginsAndModules,
49-
ClusterState,
50-
XPackLicenseState,
51-
DeprecationIssue>> SINGLE_NODE_CHECKS = List.of(
52-
NodeDeprecationChecks::checkMultipleDataPaths,
53-
NodeDeprecationChecks::checkDataPathsList,
54-
NodeDeprecationChecks::checkSharedDataPathSetting,
55-
NodeDeprecationChecks::checkReservedPrefixedRealmNames,
56-
NodeDeprecationChecks::checkExporterUseIngestPipelineSettings,
57-
NodeDeprecationChecks::checkExporterPipelineMasterTimeoutSetting,
58-
NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting,
59-
NodeDeprecationChecks::checkMonitoringSettingHistoryDuration,
60-
NodeDeprecationChecks::checkMonitoringSettingHistoryDuration,
61-
NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecovery,
62-
NodeDeprecationChecks::checkMonitoringSettingCollectIndices,
63-
NodeDeprecationChecks::checkMonitoringSettingCollectCcrTimeout,
64-
NodeDeprecationChecks::checkMonitoringSettingCollectEnrichStatsTimeout,
65-
NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecoveryStatsTimeout,
66-
NodeDeprecationChecks::checkMonitoringSettingCollectIndexStatsTimeout,
67-
NodeDeprecationChecks::checkMonitoringSettingCollectMlJobStatsTimeout,
68-
NodeDeprecationChecks::checkMonitoringSettingCollectNodeStatsTimeout,
69-
NodeDeprecationChecks::checkMonitoringSettingCollectClusterStatsTimeout,
70-
NodeDeprecationChecks::checkMonitoringSettingExportersHost,
71-
NodeDeprecationChecks::checkMonitoringSettingExportersBulkTimeout,
72-
NodeDeprecationChecks::checkMonitoringSettingExportersConnectionTimeout,
73-
NodeDeprecationChecks::checkMonitoringSettingExportersConnectionReadTimeout,
74-
NodeDeprecationChecks::checkMonitoringSettingExportersAuthUsername,
75-
NodeDeprecationChecks::checkMonitoringSettingExportersAuthPass,
76-
NodeDeprecationChecks::checkMonitoringSettingExportersSSL,
77-
NodeDeprecationChecks::checkMonitoringSettingExportersProxyBase,
78-
NodeDeprecationChecks::checkMonitoringSettingExportersSniffEnabled,
79-
NodeDeprecationChecks::checkMonitoringSettingExportersHeaders,
80-
NodeDeprecationChecks::checkMonitoringSettingExportersTemplateTimeout,
81-
NodeDeprecationChecks::checkMonitoringSettingExportersMasterTimeout,
82-
NodeDeprecationChecks::checkMonitoringSettingExportersEnabled,
83-
NodeDeprecationChecks::checkMonitoringSettingExportersType,
84-
NodeDeprecationChecks::checkMonitoringSettingExportersAlertsEnabled,
85-
NodeDeprecationChecks::checkMonitoringSettingExportersAlertsBlacklist,
86-
NodeDeprecationChecks::checkMonitoringSettingExportersIndexNameTimeFormat,
87-
NodeDeprecationChecks::checkMonitoringSettingDecommissionAlerts,
88-
NodeDeprecationChecks::checkMonitoringSettingEsCollectionEnabled,
89-
NodeDeprecationChecks::checkMonitoringSettingCollectionEnabled,
90-
NodeDeprecationChecks::checkMonitoringSettingCollectionInterval,
91-
NodeDeprecationChecks::checkScriptContextCache,
92-
NodeDeprecationChecks::checkScriptContextCompilationsRateLimitSetting,
93-
NodeDeprecationChecks::checkScriptContextCacheSizeSetting,
94-
NodeDeprecationChecks::checkScriptContextCacheExpirationSetting,
95-
NodeDeprecationChecks::checkEnforceDefaultTierPreferenceSetting,
96-
NodeDeprecationChecks::checkLifecyleStepMasterTimeoutSetting,
97-
NodeDeprecationChecks::checkEqlEnabledSetting,
98-
NodeDeprecationChecks::checkNodeAttrData,
99-
NodeDeprecationChecks::checkWatcherBulkConcurrentRequestsSetting,
100-
NodeDeprecationChecks::checkTracingApmSettings
101-
);
46+
NodeDeprecationCheck<Settings, PluginsAndModules, ClusterState, XPackLicenseState, DeprecationIssue>> SINGLE_NODE_CHECKS = List.of(
47+
NodeDeprecationChecks::checkMultipleDataPaths,
48+
NodeDeprecationChecks::checkDataPathsList,
49+
NodeDeprecationChecks::checkSharedDataPathSetting,
50+
NodeDeprecationChecks::checkReservedPrefixedRealmNames,
51+
NodeDeprecationChecks::checkExporterUseIngestPipelineSettings,
52+
NodeDeprecationChecks::checkExporterPipelineMasterTimeoutSetting,
53+
NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting,
54+
NodeDeprecationChecks::checkMonitoringSettingHistoryDuration,
55+
NodeDeprecationChecks::checkMonitoringSettingHistoryDuration,
56+
NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecovery,
57+
NodeDeprecationChecks::checkMonitoringSettingCollectIndices,
58+
NodeDeprecationChecks::checkMonitoringSettingCollectCcrTimeout,
59+
NodeDeprecationChecks::checkMonitoringSettingCollectEnrichStatsTimeout,
60+
NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecoveryStatsTimeout,
61+
NodeDeprecationChecks::checkMonitoringSettingCollectIndexStatsTimeout,
62+
NodeDeprecationChecks::checkMonitoringSettingCollectMlJobStatsTimeout,
63+
NodeDeprecationChecks::checkMonitoringSettingCollectNodeStatsTimeout,
64+
NodeDeprecationChecks::checkMonitoringSettingCollectClusterStatsTimeout,
65+
NodeDeprecationChecks::checkMonitoringSettingExportersHost,
66+
NodeDeprecationChecks::checkMonitoringSettingExportersBulkTimeout,
67+
NodeDeprecationChecks::checkMonitoringSettingExportersConnectionTimeout,
68+
NodeDeprecationChecks::checkMonitoringSettingExportersConnectionReadTimeout,
69+
NodeDeprecationChecks::checkMonitoringSettingExportersAuthUsername,
70+
NodeDeprecationChecks::checkMonitoringSettingExportersAuthPass,
71+
NodeDeprecationChecks::checkMonitoringSettingExportersSSL,
72+
NodeDeprecationChecks::checkMonitoringSettingExportersProxyBase,
73+
NodeDeprecationChecks::checkMonitoringSettingExportersSniffEnabled,
74+
NodeDeprecationChecks::checkMonitoringSettingExportersHeaders,
75+
NodeDeprecationChecks::checkMonitoringSettingExportersTemplateTimeout,
76+
NodeDeprecationChecks::checkMonitoringSettingExportersMasterTimeout,
77+
NodeDeprecationChecks::checkMonitoringSettingExportersEnabled,
78+
NodeDeprecationChecks::checkMonitoringSettingExportersType,
79+
NodeDeprecationChecks::checkMonitoringSettingExportersAlertsEnabled,
80+
NodeDeprecationChecks::checkMonitoringSettingExportersAlertsBlacklist,
81+
NodeDeprecationChecks::checkMonitoringSettingExportersIndexNameTimeFormat,
82+
NodeDeprecationChecks::checkMonitoringSettingDecommissionAlerts,
83+
NodeDeprecationChecks::checkMonitoringSettingEsCollectionEnabled,
84+
NodeDeprecationChecks::checkMonitoringSettingCollectionEnabled,
85+
NodeDeprecationChecks::checkMonitoringSettingCollectionInterval,
86+
NodeDeprecationChecks::checkScriptContextCache,
87+
NodeDeprecationChecks::checkScriptContextCompilationsRateLimitSetting,
88+
NodeDeprecationChecks::checkScriptContextCacheSizeSetting,
89+
NodeDeprecationChecks::checkScriptContextCacheExpirationSetting,
90+
NodeDeprecationChecks::checkEnforceDefaultTierPreferenceSetting,
91+
NodeDeprecationChecks::checkLifecyleStepMasterTimeoutSetting,
92+
NodeDeprecationChecks::checkEqlEnabledSetting,
93+
NodeDeprecationChecks::checkNodeAttrData,
94+
NodeDeprecationChecks::checkWatcherBulkConcurrentRequestsSetting,
95+
NodeDeprecationChecks::checkTracingApmSettings
96+
);
10297

10398
static DeprecationIssue checkDeprecatedSetting(
10499
final Settings clusterSettings,
@@ -1062,4 +1057,9 @@ static DeprecationIssue checkTracingApmSettings(
10621057
DeprecationIssue.Level.CRITICAL
10631058
);
10641059
}
1060+
1061+
@FunctionalInterface
1062+
public interface NodeDeprecationCheck<A, B, C, D, R> {
1063+
R apply(A first, B second, C third, D fourth);
1064+
}
10651065
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import java.util.HashMap;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.function.Function;
2324

24-
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.filterChecks;
2525
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_COMMON_DETAIL;
2626
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_HELP_URL;
2727
import static org.elasticsearch.xpack.deprecation.LegacyTiersDetection.DEPRECATION_MESSAGE;
@@ -70,7 +70,10 @@ Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
7070
String name = entry.getKey();
7171
ComposableIndexTemplate template = entry.getValue();
7272

73-
List<DeprecationIssue> issuesForSingleIndexTemplate = filterChecks(indexTemplateChecks, c -> c.apply(template));
73+
List<DeprecationIssue> issuesForSingleIndexTemplate = indexTemplateChecks.stream()
74+
.map(c -> c.apply(template))
75+
.filter(Objects::nonNull)
76+
.toList();
7477
if (issuesForSingleIndexTemplate.isEmpty() == false) {
7578
issues.computeIfAbsent(name, ignored -> new ArrayList<>()).addAll(issuesForSingleIndexTemplate);
7679
}
@@ -79,7 +82,10 @@ Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
7982
String name = entry.getKey();
8083
ComponentTemplate template = entry.getValue();
8184

82-
List<DeprecationIssue> issuesForSingleIndexTemplate = filterChecks(componentTemplateChecks, c -> c.apply(template));
85+
List<DeprecationIssue> issuesForSingleIndexTemplate = componentTemplateChecks.stream()
86+
.map(c -> c.apply(template))
87+
.filter(Objects::nonNull)
88+
.toList();
8389
if (issuesForSingleIndexTemplate.isEmpty() == false) {
8490
issues.computeIfAbsent(name, ignored -> new ArrayList<>()).addAll(issuesForSingleIndexTemplate);
8591
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.cluster.metadata.Template;
2727
import org.elasticsearch.cluster.service.ClusterService;
2828
import org.elasticsearch.common.regex.Regex;
29+
import org.elasticsearch.common.settings.Setting;
2930
import org.elasticsearch.common.settings.Settings;
3031
import org.elasticsearch.core.Tuple;
3132
import org.elasticsearch.injection.guice.Inject;
@@ -50,6 +51,11 @@
5051
public class TransportDeprecationInfoAction extends TransportMasterNodeReadAction<
5152
DeprecationInfoAction.Request,
5253
DeprecationInfoAction.Response> {
54+
public static final Setting<List<String>> SKIP_DEPRECATIONS_SETTING = Setting.stringListSetting(
55+
"deprecation.skip_deprecated_settings",
56+
Setting.Property.NodeScope,
57+
Setting.Property.Dynamic
58+
);
5359
private static final List<DeprecationChecker> PLUGIN_CHECKERS = List.of(new MlDeprecationChecker());
5460

5561
private final NodeClient client;
@@ -86,7 +92,7 @@ public TransportDeprecationInfoAction(
8692
this.indexNameExpressionResolver = indexNameExpressionResolver;
8793
this.settings = settings;
8894
this.xContentRegistry = xContentRegistry;
89-
skipTheseDeprecations = DeprecationChecks.SKIP_DEPRECATIONS_SETTING.get(settings);
95+
skipTheseDeprecations = SKIP_DEPRECATIONS_SETTING.get(settings);
9096
nodeDeprecationChecker = new NodeDeprecationChecker(threadPool);
9197
clusterDeprecationChecker = new ClusterDeprecationChecker(xContentRegistry);
9298
resourceDeprecationCheckers = List.of(
@@ -96,8 +102,7 @@ public TransportDeprecationInfoAction(
96102
new IlmPolicyDeprecationChecker()
97103
);
98104
// Safe to register this here because it happens synchronously before the cluster service is started:
99-
clusterService.getClusterSettings()
100-
.addSettingsUpdateConsumer(DeprecationChecks.SKIP_DEPRECATIONS_SETTING, this::setSkipDeprecations);
105+
clusterService.getClusterSettings().addSettingsUpdateConsumer(SKIP_DEPRECATIONS_SETTING, this::setSkipDeprecations);
101106
}
102107

103108
private <T> void setSkipDeprecations(List<String> skipDeprecations) {

0 commit comments

Comments
 (0)