1111import org .elasticsearch .action .ActionListener ;
1212import org .elasticsearch .action .support .ActionFilters ;
1313import org .elasticsearch .action .support .ChannelActionListener ;
14- import org .elasticsearch .action .support .local .TransportLocalClusterStateAction ;
15- import org .elasticsearch .cluster .ClusterState ;
14+ import org .elasticsearch .action .support .local .TransportLocalProjectMetadataAction ;
15+ import org .elasticsearch .cluster .ProjectState ;
1616import org .elasticsearch .cluster .block .ClusterBlockException ;
1717import org .elasticsearch .cluster .block .ClusterBlockLevel ;
1818import org .elasticsearch .cluster .metadata .IndexMetadata ;
1919import org .elasticsearch .cluster .metadata .IndexNameExpressionResolver ;
2020import org .elasticsearch .cluster .metadata .LifecycleExecutionState ;
21- import org .elasticsearch .cluster .metadata .Metadata ;
21+ import org .elasticsearch .cluster .metadata .ProjectMetadata ;
2222import org .elasticsearch .cluster .project .ProjectResolver ;
2323import org .elasticsearch .cluster .service .ClusterService ;
2424import org .elasticsearch .common .Strings ;
5252import static org .elasticsearch .index .IndexSettings .LIFECYCLE_ORIGINATION_DATE ;
5353import static org .elasticsearch .xpack .core .ilm .WaitForRolloverReadyStep .applyDefaultConditions ;
5454
55- public class TransportExplainLifecycleAction extends TransportLocalClusterStateAction <ExplainLifecycleRequest , ExplainLifecycleResponse > {
55+ public class TransportExplainLifecycleAction extends TransportLocalProjectMetadataAction <
56+ ExplainLifecycleRequest ,
57+ ExplainLifecycleResponse > {
5658
5759 private final NamedXContentRegistry xContentRegistry ;
5860 private final IndexNameExpressionResolver indexNameExpressionResolver ;
@@ -78,7 +80,8 @@ public TransportExplainLifecycleAction(
7880 actionFilters ,
7981 transportService .getTaskManager (),
8082 clusterService ,
81- threadPool .executor (ThreadPool .Names .MANAGEMENT )
83+ threadPool .executor (ThreadPool .Names .MANAGEMENT ),
84+ projectResolver
8285 );
8386 this .xContentRegistry = xContentRegistry ;
8487 this .indexNameExpressionResolver = indexNameExpressionResolver ;
@@ -95,29 +98,33 @@ public TransportExplainLifecycleAction(
9598 }
9699
97100 @ Override
98- protected ClusterBlockException checkBlock (ExplainLifecycleRequest request , ClusterState state ) {
99- return state .blocks ()
100- .indicesBlockedException (ClusterBlockLevel .METADATA_READ , indexNameExpressionResolver .concreteIndexNames (state , request ));
101+ protected ClusterBlockException checkBlock (ExplainLifecycleRequest request , ProjectState project ) {
102+ return project .blocks ()
103+ .indicesBlockedException (
104+ project .projectId (),
105+ ClusterBlockLevel .METADATA_READ ,
106+ indexNameExpressionResolver .concreteIndexNames (project .metadata (), request )
107+ );
101108 }
102109
103110 @ Override
104111 protected void localClusterStateOperation (
105112 Task task ,
106113 ExplainLifecycleRequest request ,
107- final ClusterState state ,
114+ ProjectState project ,
108115 ActionListener <ExplainLifecycleResponse > listener
109116 ) {
110- String [] concreteIndices = indexNameExpressionResolver .concreteIndexNames (state , request );
117+ String [] concreteIndices = indexNameExpressionResolver .concreteIndexNames (project . metadata () , request );
111118 boolean rolloverOnlyIfHasDocuments = LifecycleSettings .LIFECYCLE_ROLLOVER_ONLY_IF_HAS_DOCUMENTS_SETTING .get (
112- state .metadata ().settings ()
119+ project . cluster () .metadata ().settings ()
113120 );
114121 Map <String , IndexLifecycleExplainResponse > indexResponses = new TreeMap <>();
115122 for (String index : concreteIndices ) {
116123 final IndexLifecycleExplainResponse indexResponse ;
117124 try {
118125 indexResponse = getIndexLifecycleExplainResponse (
119126 index ,
120- state .metadata (),
127+ project .metadata (),
121128 request .onlyErrors (),
122129 request .onlyManaged (),
123130 xContentRegistry ,
@@ -140,13 +147,12 @@ protected void localClusterStateOperation(
140147 @ Nullable
141148 static IndexLifecycleExplainResponse getIndexLifecycleExplainResponse (
142149 String indexName ,
143- Metadata metadata ,
150+ ProjectMetadata project ,
144151 boolean onlyErrors ,
145152 boolean onlyManaged ,
146153 NamedXContentRegistry xContentRegistry ,
147154 boolean rolloverOnlyIfHasDocuments
148155 ) throws IOException {
149- final var project = metadata .getProject ();
150156 IndexMetadata indexMetadata = project .index (indexName );
151157 Settings idxSettings = indexMetadata .getSettings ();
152158 LifecycleExecutionState lifecycleState = indexMetadata .getLifecycleExecutionState ();
0 commit comments