32
32
33
33
package org .opensearch .rest .action .cat ;
34
34
35
+ import org .opensearch .OpenSearchParseException ;
35
36
import org .opensearch .action .ActionListener ;
36
37
import org .opensearch .action .ActionResponse ;
37
38
import org .opensearch .action .admin .cluster .health .ClusterHealthRequest ;
52
53
import org .opensearch .cluster .metadata .IndexMetadata ;
53
54
import org .opensearch .common .Strings ;
54
55
import org .opensearch .common .Table ;
56
+ import org .opensearch .common .logging .DeprecationLogger ;
55
57
import org .opensearch .common .settings .Settings ;
56
58
import org .opensearch .common .time .DateFormatter ;
57
59
import org .opensearch .common .unit .TimeValue ;
82
84
public class RestIndicesAction extends AbstractCatAction {
83
85
84
86
private static final DateFormatter STRICT_DATE_TIME_FORMATTER = DateFormatter .forPattern ("strict_date_time" );
87
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (RestIndicesAction .class );
88
+ private static final String MASTER_TIMEOUT_DEPRECATED_MESSAGE =
89
+ "Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version." ;
90
+ private static final String DUPLICATE_PARAMETER_ERROR_MESSAGE =
91
+ "Please only use one of the request parameters [master_timeout, cluster_manager_timeout]." ;
85
92
86
93
@ Override
87
94
public List <Route > routes () {
@@ -109,7 +116,16 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli
109
116
final String [] indices = Strings .splitStringByCommaToArray (request .param ("index" ));
110
117
final IndicesOptions indicesOptions = IndicesOptions .fromRequest (request , IndicesOptions .strictExpand ());
111
118
final boolean local = request .paramAsBoolean ("local" , false );
112
- final TimeValue masterNodeTimeout = request .paramAsTime ("master_timeout" , DEFAULT_MASTER_NODE_TIMEOUT );
119
+ TimeValue clusterManagerTimeout = request .paramAsTime ("cluster_manager_timeout" , DEFAULT_MASTER_NODE_TIMEOUT );
120
+ // Remove the if condition and statements inside after removing MASTER_ROLE.
121
+ if (request .hasParam ("master_timeout" )) {
122
+ deprecationLogger .deprecate ("cat_indices_master_timeout_parameter" , MASTER_TIMEOUT_DEPRECATED_MESSAGE );
123
+ if (request .hasParam ("cluster_manager_timeout" )) {
124
+ throw new OpenSearchParseException (DUPLICATE_PARAMETER_ERROR_MESSAGE );
125
+ }
126
+ clusterManagerTimeout = request .paramAsTime ("master_timeout" , DEFAULT_MASTER_NODE_TIMEOUT );
127
+ }
128
+ final TimeValue clusterManagerNodeTimeout = clusterManagerTimeout ;
113
129
final boolean includeUnloadedSegments = request .paramAsBoolean ("include_unloaded_segments" , false );
114
130
115
131
return channel -> {
@@ -120,56 +136,66 @@ public RestResponse buildResponse(final Table table) throws Exception {
120
136
}
121
137
});
122
138
123
- sendGetSettingsRequest (indices , indicesOptions , local , masterNodeTimeout , client , new ActionListener <GetSettingsResponse >() {
124
- @ Override
125
- public void onResponse (final GetSettingsResponse getSettingsResponse ) {
126
- final GroupedActionListener <ActionResponse > groupedListener = createGroupedListener (request , 4 , listener );
127
- groupedListener .onResponse (getSettingsResponse );
128
-
129
- // The list of indices that will be returned is determined by the indices returned from the Get Settings call.
130
- // All the other requests just provide additional detail, and wildcards may be resolved differently depending on the
131
- // type of request in the presence of security plugins (looking at you, ClusterHealthRequest), so
132
- // force the IndicesOptions for all the sub-requests to be as inclusive as possible.
133
- final IndicesOptions subRequestIndicesOptions = IndicesOptions .lenientExpandHidden ();
134
-
135
- // Indices that were successfully resolved during the get settings request might be deleted when the subsequent cluster
136
- // state, cluster health and indices stats requests execute. We have to distinguish two cases:
137
- // 1) the deleted index was explicitly passed as parameter to the /_cat/indices request. In this case we want the
138
- // subsequent requests to fail.
139
- // 2) the deleted index was resolved as part of a wildcard or _all. In this case, we want the subsequent requests not to
140
- // fail on the deleted index (as we want to ignore wildcards that cannot be resolved).
141
- // This behavior can be ensured by letting the cluster state, cluster health and indices stats requests re-resolve the
142
- // index names with the same indices options that we used for the initial cluster state request (strictExpand).
143
- sendIndicesStatsRequest (
144
- indices ,
145
- subRequestIndicesOptions ,
146
- includeUnloadedSegments ,
147
- client ,
148
- ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
149
- );
150
- sendClusterStateRequest (
151
- indices ,
152
- subRequestIndicesOptions ,
153
- local ,
154
- masterNodeTimeout ,
155
- client ,
156
- ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
157
- );
158
- sendClusterHealthRequest (
159
- indices ,
160
- subRequestIndicesOptions ,
161
- local ,
162
- masterNodeTimeout ,
163
- client ,
164
- ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
165
- );
166
- }
167
-
168
- @ Override
169
- public void onFailure (final Exception e ) {
170
- listener .onFailure (e );
139
+ sendGetSettingsRequest (
140
+ indices ,
141
+ indicesOptions ,
142
+ local ,
143
+ clusterManagerNodeTimeout ,
144
+ client ,
145
+ new ActionListener <GetSettingsResponse >() {
146
+ @ Override
147
+ public void onResponse (final GetSettingsResponse getSettingsResponse ) {
148
+ final GroupedActionListener <ActionResponse > groupedListener = createGroupedListener (request , 4 , listener );
149
+ groupedListener .onResponse (getSettingsResponse );
150
+
151
+ // The list of indices that will be returned is determined by the indices returned from the Get Settings call.
152
+ // All the other requests just provide additional detail, and wildcards may be resolved differently depending on the
153
+ // type of request in the presence of security plugins (looking at you, ClusterHealthRequest), so
154
+ // force the IndicesOptions for all the sub-requests to be as inclusive as possible.
155
+ final IndicesOptions subRequestIndicesOptions = IndicesOptions .lenientExpandHidden ();
156
+
157
+ // Indices that were successfully resolved during the get settings request might be deleted when the subsequent
158
+ // cluster
159
+ // state, cluster health and indices stats requests execute. We have to distinguish two cases:
160
+ // 1) the deleted index was explicitly passed as parameter to the /_cat/indices request. In this case we want the
161
+ // subsequent requests to fail.
162
+ // 2) the deleted index was resolved as part of a wildcard or _all. In this case, we want the subsequent requests
163
+ // not to
164
+ // fail on the deleted index (as we want to ignore wildcards that cannot be resolved).
165
+ // This behavior can be ensured by letting the cluster state, cluster health and indices stats requests re-resolve
166
+ // the
167
+ // index names with the same indices options that we used for the initial cluster state request (strictExpand).
168
+ sendIndicesStatsRequest (
169
+ indices ,
170
+ subRequestIndicesOptions ,
171
+ includeUnloadedSegments ,
172
+ client ,
173
+ ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
174
+ );
175
+ sendClusterStateRequest (
176
+ indices ,
177
+ subRequestIndicesOptions ,
178
+ local ,
179
+ clusterManagerNodeTimeout ,
180
+ client ,
181
+ ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
182
+ );
183
+ sendClusterHealthRequest (
184
+ indices ,
185
+ subRequestIndicesOptions ,
186
+ local ,
187
+ clusterManagerNodeTimeout ,
188
+ client ,
189
+ ActionListener .wrap (groupedListener ::onResponse , groupedListener ::onFailure )
190
+ );
191
+ }
192
+
193
+ @ Override
194
+ public void onFailure (final Exception e ) {
195
+ listener .onFailure (e );
196
+ }
171
197
}
172
- } );
198
+ );
173
199
};
174
200
}
175
201
0 commit comments