7
7
package org .elasticsearch .xpack .deprecation ;
8
8
9
9
import org .elasticsearch .Version ;
10
- import org .elasticsearch .cluster .ClusterState ;
11
10
import org .elasticsearch .cluster .metadata .IndexMetadata ;
12
11
import org .elasticsearch .cluster .metadata .IndexNameExpressionResolver ;
13
12
import org .elasticsearch .cluster .metadata .MappingMetadata ;
13
+ import org .elasticsearch .cluster .metadata .ProjectMetadata ;
14
14
import org .elasticsearch .common .TriFunction ;
15
15
import org .elasticsearch .common .time .DateFormatter ;
16
16
import org .elasticsearch .common .time .LegacyFormatNames ;
@@ -44,7 +44,7 @@ public class IndexDeprecationChecker implements ResourceDeprecationChecker {
44
44
public static final String NAME = "index_settings" ;
45
45
46
46
private final IndexNameExpressionResolver indexNameExpressionResolver ;
47
- private final List <TriFunction <IndexMetadata , ClusterState , Map <String , List <String >>, DeprecationIssue >> checks = List .of (
47
+ private final List <TriFunction <IndexMetadata , ProjectMetadata , Map <String , List <String >>, DeprecationIssue >> checks = List .of (
48
48
this ::oldIndicesCheck ,
49
49
this ::ignoredOldIndicesCheck ,
50
50
this ::translogRetentionSettingCheck ,
@@ -60,17 +60,17 @@ public IndexDeprecationChecker(IndexNameExpressionResolver indexNameExpressionRe
60
60
61
61
@ Override
62
62
public Map <String , List <DeprecationIssue >> check (
63
- ClusterState clusterState ,
63
+ ProjectMetadata project ,
64
64
DeprecationInfoAction .Request request ,
65
65
TransportDeprecationInfoAction .PrecomputedData precomputedData
66
66
) {
67
67
Map <String , List <DeprecationIssue >> indexSettingsIssues = new HashMap <>();
68
- String [] concreteIndexNames = indexNameExpressionResolver .concreteIndexNames (clusterState , request );
68
+ String [] concreteIndexNames = indexNameExpressionResolver .concreteIndexNames (project , request );
69
69
Map <String , List <String >> indexToTransformIds = indexToTransformIds (precomputedData .transformConfigs ());
70
70
for (String concreteIndex : concreteIndexNames ) {
71
- IndexMetadata indexMetadata = clusterState . getMetadata (). getProject () .index (concreteIndex );
71
+ IndexMetadata indexMetadata = project .index (concreteIndex );
72
72
List <DeprecationIssue > singleIndexIssues = checks .stream ()
73
- .map (c -> c .apply (indexMetadata , clusterState , indexToTransformIds ))
73
+ .map (c -> c .apply (indexMetadata , project , indexToTransformIds ))
74
74
.filter (Objects ::nonNull )
75
75
.toList ();
76
76
if (singleIndexIssues .isEmpty () == false ) {
@@ -90,13 +90,13 @@ public String getName() {
90
90
91
91
private DeprecationIssue oldIndicesCheck (
92
92
IndexMetadata indexMetadata ,
93
- ClusterState clusterState ,
93
+ ProjectMetadata project ,
94
94
Map <String , List <String >> indexToTransformIds
95
95
) {
96
96
// TODO: this check needs to be revised. It's trivially true right now.
97
97
IndexVersion currentCompatibilityVersion = indexMetadata .getCompatibilityVersion ();
98
98
// We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
99
- if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , false , false ) && isNotDataStreamIndex (indexMetadata , clusterState )) {
99
+ if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , false , false ) && isNotDataStreamIndex (indexMetadata , project )) {
100
100
var transforms = transformIdsForIndex (indexMetadata , indexToTransformIds );
101
101
if (transforms .isEmpty () == false ) {
102
102
return new DeprecationIssue (
@@ -134,12 +134,12 @@ private List<String> transformIdsForIndex(IndexMetadata indexMetadata, Map<Strin
134
134
135
135
private DeprecationIssue ignoredOldIndicesCheck (
136
136
IndexMetadata indexMetadata ,
137
- ClusterState clusterState ,
137
+ ProjectMetadata project ,
138
138
Map <String , List <String >> indexToTransformIds
139
139
) {
140
140
IndexVersion currentCompatibilityVersion = indexMetadata .getCompatibilityVersion ();
141
141
// We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
142
- if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , true , false ) && isNotDataStreamIndex (indexMetadata , clusterState )) {
142
+ if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , true , false ) && isNotDataStreamIndex (indexMetadata , project )) {
143
143
var transforms = transformIdsForIndex (indexMetadata , indexToTransformIds );
144
144
if (transforms .isEmpty () == false ) {
145
145
return new DeprecationIssue (
@@ -175,13 +175,13 @@ private DeprecationIssue ignoredOldIndicesCheck(
175
175
return null ;
176
176
}
177
177
178
- private boolean isNotDataStreamIndex (IndexMetadata indexMetadata , ClusterState clusterState ) {
179
- return clusterState . metadata (). getProject () .findDataStreams (indexMetadata .getIndex ().getName ()).isEmpty ();
178
+ private boolean isNotDataStreamIndex (IndexMetadata indexMetadata , ProjectMetadata project ) {
179
+ return project .findDataStreams (indexMetadata .getIndex ().getName ()).isEmpty ();
180
180
}
181
181
182
182
private DeprecationIssue translogRetentionSettingCheck (
183
183
IndexMetadata indexMetadata ,
184
- ClusterState clusterState ,
184
+ ProjectMetadata project ,
185
185
Map <String , List <String >> ignored
186
186
) {
187
187
final boolean softDeletesEnabled = IndexSettings .INDEX_SOFT_DELETES_SETTING .get (indexMetadata .getSettings ());
@@ -210,7 +210,7 @@ private DeprecationIssue translogRetentionSettingCheck(
210
210
return null ;
211
211
}
212
212
213
- private DeprecationIssue checkIndexDataPath (IndexMetadata indexMetadata , ClusterState clusterState , Map <String , List <String >> ignored ) {
213
+ private DeprecationIssue checkIndexDataPath (IndexMetadata indexMetadata , ProjectMetadata project , Map <String , List <String >> ignored ) {
214
214
if (IndexMetadata .INDEX_DATA_PATH_SETTING .exists (indexMetadata .getSettings ())) {
215
215
final String message = String .format (
216
216
Locale .ROOT ,
@@ -226,7 +226,7 @@ private DeprecationIssue checkIndexDataPath(IndexMetadata indexMetadata, Cluster
226
226
227
227
private DeprecationIssue storeTypeSettingCheck (
228
228
IndexMetadata indexMetadata ,
229
- ClusterState clusterState ,
229
+ ProjectMetadata project ,
230
230
Map <String , List <String >> ignored
231
231
) {
232
232
final String storeType = IndexModule .INDEX_STORE_TYPE_SETTING .get (indexMetadata .getSettings ());
@@ -247,7 +247,7 @@ private DeprecationIssue storeTypeSettingCheck(
247
247
248
248
private DeprecationIssue legacyRoutingSettingCheck (
249
249
IndexMetadata indexMetadata ,
250
- ClusterState clusterState ,
250
+ ProjectMetadata project ,
251
251
Map <String , List <String >> ignored
252
252
) {
253
253
List <String > deprecatedSettings = LegacyTiersDetection .getDeprecatedFilteredAllocationSettings (indexMetadata .getSettings ());
@@ -339,7 +339,7 @@ private List<String> findInPropertiesRecursively(
339
339
340
340
private DeprecationIssue deprecatedCamelCasePattern (
341
341
IndexMetadata indexMetadata ,
342
- ClusterState clusterState ,
342
+ ProjectMetadata project ,
343
343
Map <String , List <String >> ignored
344
344
) {
345
345
List <String > fields = new ArrayList <>();
0 commit comments