5
5
*/
6
6
package org .elasticsearch .xpack .core .deprecation ;
7
7
8
+ import org .elasticsearch .Version ;
8
9
import org .elasticsearch .action .Action ;
9
10
import org .elasticsearch .action .ActionRequestValidationException ;
10
11
import org .elasticsearch .action .ActionResponse ;
23
24
import org .elasticsearch .common .io .stream .StreamOutput ;
24
25
import org .elasticsearch .common .xcontent .ToXContentObject ;
25
26
import org .elasticsearch .common .xcontent .XContentBuilder ;
27
+ import org .elasticsearch .xpack .core .ml .datafeed .DatafeedConfig ;
26
28
27
29
import java .io .IOException ;
30
+ import java .util .ArrayList ;
28
31
import java .util .Arrays ;
32
+ import java .util .Collections ;
29
33
import java .util .HashMap ;
30
34
import java .util .List ;
31
35
import java .util .Map ;
@@ -73,16 +77,19 @@ public static class Response extends ActionResponse implements ToXContentObject
73
77
private List <DeprecationIssue > clusterSettingsIssues ;
74
78
private List <DeprecationIssue > nodeSettingsIssues ;
75
79
private Map <String , List <DeprecationIssue >> indexSettingsIssues ;
80
+ private List <DeprecationIssue > mlSettingsIssues ;
76
81
77
82
public Response () {
78
83
}
79
84
80
85
public Response (List <DeprecationIssue > clusterSettingsIssues ,
81
86
List <DeprecationIssue > nodeSettingsIssues ,
82
- Map <String , List <DeprecationIssue >> indexSettingsIssues ) {
87
+ Map <String , List <DeprecationIssue >> indexSettingsIssues ,
88
+ List <DeprecationIssue > mlSettingsIssues ) {
83
89
this .clusterSettingsIssues = clusterSettingsIssues ;
84
90
this .nodeSettingsIssues = nodeSettingsIssues ;
85
91
this .indexSettingsIssues = indexSettingsIssues ;
92
+ this .mlSettingsIssues = mlSettingsIssues ;
86
93
}
87
94
88
95
public List <DeprecationIssue > getClusterSettingsIssues () {
@@ -97,12 +104,22 @@ public Map<String, List<DeprecationIssue>> getIndexSettingsIssues() {
97
104
return indexSettingsIssues ;
98
105
}
99
106
107
+ public List <DeprecationIssue > getMlSettingsIssues () {
108
+ return mlSettingsIssues ;
109
+ }
110
+
100
111
@ Override
101
112
public void readFrom (StreamInput in ) throws IOException {
102
113
super .readFrom (in );
103
114
clusterSettingsIssues = in .readList (DeprecationIssue ::new );
104
115
nodeSettingsIssues = in .readList (DeprecationIssue ::new );
105
116
indexSettingsIssues = in .readMapOfLists (StreamInput ::readString , DeprecationIssue ::new );
117
+ if ((in .getVersion ().onOrAfter (Version .V_5_6_5 ) && in .getVersion ().before (Version .V_6_0_0 ))
118
+ || in .getVersion ().onOrAfter (Version .V_6_7_0 )) {
119
+ mlSettingsIssues = in .readList (DeprecationIssue ::new );
120
+ } else {
121
+ mlSettingsIssues = Collections .emptyList ();
122
+ }
106
123
}
107
124
108
125
@ Override
@@ -111,6 +128,10 @@ public void writeTo(StreamOutput out) throws IOException {
111
128
out .writeList (clusterSettingsIssues );
112
129
out .writeList (nodeSettingsIssues );
113
130
out .writeMapOfLists (indexSettingsIssues , StreamOutput ::writeString , (o , v ) -> v .writeTo (o ));
131
+ if ((out .getVersion ().onOrAfter (Version .V_5_6_5 ) && out .getVersion ().before (Version .V_6_0_0 ))
132
+ || out .getVersion ().onOrAfter (Version .V_6_7_0 )) {
133
+ out .writeList (mlSettingsIssues );
134
+ }
114
135
}
115
136
116
137
@ Override
@@ -119,24 +140,25 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
119
140
.array ("cluster_settings" , clusterSettingsIssues .toArray ())
120
141
.array ("node_settings" , nodeSettingsIssues .toArray ())
121
142
.field ("index_settings" )
122
- .map (indexSettingsIssues )
143
+ .map (indexSettingsIssues )
144
+ .array ("ml_settings" , mlSettingsIssues .toArray ())
123
145
.endObject ();
124
146
}
125
147
126
-
127
148
@ Override
128
149
public boolean equals (Object o ) {
129
150
if (this == o ) return true ;
130
151
if (o == null || getClass () != o .getClass ()) return false ;
131
152
Response response = (Response ) o ;
132
153
return Objects .equals (clusterSettingsIssues , response .clusterSettingsIssues ) &&
133
154
Objects .equals (nodeSettingsIssues , response .nodeSettingsIssues ) &&
134
- Objects .equals (indexSettingsIssues , response .indexSettingsIssues );
155
+ Objects .equals (indexSettingsIssues , response .indexSettingsIssues ) &&
156
+ Objects .equals (mlSettingsIssues , response .mlSettingsIssues );
135
157
}
136
158
137
159
@ Override
138
160
public int hashCode () {
139
- return Objects .hash (clusterSettingsIssues , nodeSettingsIssues , indexSettingsIssues );
161
+ return Objects .hash (clusterSettingsIssues , nodeSettingsIssues , indexSettingsIssues , mlSettingsIssues );
140
162
}
141
163
142
164
/**
@@ -151,22 +173,30 @@ public int hashCode() {
151
173
* @param indexNameExpressionResolver Used to resolve indices into their concrete names
152
174
* @param indices The list of index expressions to evaluate using `indexNameExpressionResolver`
153
175
* @param indicesOptions The options to use when resolving and filtering which indices to check
176
+ * @param datafeeds The ml datafeed configurations
154
177
* @param clusterSettingsChecks The list of cluster-level checks
155
178
* @param nodeSettingsChecks The list of node-level checks
156
179
* @param indexSettingsChecks The list of index-level checks that will be run across all specified
157
180
* concrete indices
181
+ * @param mlSettingsCheck The list of ml checks
158
182
* @return The list of deprecation issues found in the cluster
159
183
*/
160
184
public static DeprecationInfoAction .Response from (List <NodeInfo > nodesInfo , List <NodeStats > nodesStats , ClusterState state ,
161
- IndexNameExpressionResolver indexNameExpressionResolver ,
162
- String [] indices , IndicesOptions indicesOptions ,
163
- List <Function <ClusterState ,DeprecationIssue >>clusterSettingsChecks ,
164
- List <BiFunction <List <NodeInfo >, List <NodeStats >, DeprecationIssue >> nodeSettingsChecks ,
165
- List <Function <IndexMetaData , DeprecationIssue >> indexSettingsChecks ) {
185
+ IndexNameExpressionResolver indexNameExpressionResolver ,
186
+ String [] indices , IndicesOptions indicesOptions ,
187
+ List <DatafeedConfig > datafeeds ,
188
+ List <Function <ClusterState ,DeprecationIssue >>clusterSettingsChecks ,
189
+ List <BiFunction <List <NodeInfo >, List <NodeStats >, DeprecationIssue >> nodeSettingsChecks ,
190
+ List <Function <IndexMetaData , DeprecationIssue >> indexSettingsChecks ,
191
+ List <Function <DatafeedConfig , DeprecationIssue >> mlSettingsCheck ) {
166
192
List <DeprecationIssue > clusterSettingsIssues = filterChecks (clusterSettingsChecks ,
167
193
(c ) -> c .apply (state ));
168
194
List <DeprecationIssue > nodeSettingsIssues = filterChecks (nodeSettingsChecks ,
169
195
(c ) -> c .apply (nodesInfo , nodesStats ));
196
+ List <DeprecationIssue > mlSettingsIssues = new ArrayList <>();
197
+ for (DatafeedConfig config : datafeeds ) {
198
+ mlSettingsIssues .addAll (filterChecks (mlSettingsCheck , (c ) -> c .apply (config )));
199
+ }
170
200
171
201
String [] concreteIndexNames = indexNameExpressionResolver .concreteIndexNames (state , indicesOptions , indices );
172
202
@@ -180,7 +210,7 @@ public static DeprecationInfoAction.Response from(List<NodeInfo> nodesInfo, List
180
210
}
181
211
}
182
212
183
- return new DeprecationInfoAction .Response (clusterSettingsIssues , nodeSettingsIssues , indexSettingsIssues );
213
+ return new DeprecationInfoAction .Response (clusterSettingsIssues , nodeSettingsIssues , indexSettingsIssues , mlSettingsIssues );
184
214
}
185
215
}
186
216
0 commit comments