37
37
import org .opensearch .action .FailedNodeException ;
38
38
import org .opensearch .action .support .ActionFilters ;
39
39
import org .opensearch .action .support .clustermanager .TransportClusterManagerNodeReadAction ;
40
+ import org .opensearch .cluster .ClusterManagerMetrics ;
40
41
import org .opensearch .cluster .ClusterState ;
41
42
import org .opensearch .cluster .block .ClusterBlockException ;
42
43
import org .opensearch .cluster .block .ClusterBlockLevel ;
@@ -88,6 +89,7 @@ public class TransportIndicesShardStoresAction extends TransportClusterManagerNo
88
89
private static final Logger logger = LogManager .getLogger (TransportIndicesShardStoresAction .class );
89
90
90
91
private final TransportNodesListGatewayStartedShards listShardStoresInfo ;
92
+ private final ClusterManagerMetrics clusterManagerMetrics ;
91
93
92
94
@ Inject
93
95
public TransportIndicesShardStoresAction (
@@ -96,7 +98,8 @@ public TransportIndicesShardStoresAction(
96
98
ThreadPool threadPool ,
97
99
ActionFilters actionFilters ,
98
100
IndexNameExpressionResolver indexNameExpressionResolver ,
99
- TransportNodesListGatewayStartedShards listShardStoresInfo
101
+ TransportNodesListGatewayStartedShards listShardStoresInfo ,
102
+ ClusterManagerMetrics clusterManagerMetrics
100
103
) {
101
104
super (
102
105
IndicesShardStoresAction .NAME ,
@@ -109,6 +112,7 @@ public TransportIndicesShardStoresAction(
109
112
true
110
113
);
111
114
this .listShardStoresInfo = listShardStoresInfo ;
115
+ this .clusterManagerMetrics = clusterManagerMetrics ;
112
116
}
113
117
114
118
@ Override
@@ -154,7 +158,7 @@ protected void clusterManagerOperation(
154
158
// we could fetch all shard store info from every node once (nNodes requests)
155
159
// we have to implement a TransportNodesAction instead of using TransportNodesListGatewayStartedShards
156
160
// for fetching shard stores info, that operates on a list of shards instead of a single shard
157
- new AsyncShardStoresInfoFetches (state .nodes (), routingNodes , shardsToFetch , listener ).start ();
161
+ new AsyncShardStoresInfoFetches (state .nodes (), routingNodes , shardsToFetch , listener , clusterManagerMetrics ).start ();
158
162
}
159
163
160
164
@ Override
@@ -175,27 +179,37 @@ private class AsyncShardStoresInfoFetches {
175
179
private final ActionListener <IndicesShardStoresResponse > listener ;
176
180
private CountDown expectedOps ;
177
181
private final Queue <InternalAsyncFetch .Response > fetchResponses ;
182
+ private final ClusterManagerMetrics clusterManagerMetrics ;
178
183
179
184
AsyncShardStoresInfoFetches (
180
185
DiscoveryNodes nodes ,
181
186
RoutingNodes routingNodes ,
182
187
Set <Tuple <ShardId , String >> shards ,
183
- ActionListener <IndicesShardStoresResponse > listener
188
+ ActionListener <IndicesShardStoresResponse > listener ,
189
+ ClusterManagerMetrics clusterManagerMetrics
184
190
) {
185
191
this .nodes = nodes ;
186
192
this .routingNodes = routingNodes ;
187
193
this .shards = shards ;
188
194
this .listener = listener ;
189
195
this .fetchResponses = new ConcurrentLinkedQueue <>();
190
196
this .expectedOps = new CountDown (shards .size ());
197
+ this .clusterManagerMetrics = clusterManagerMetrics ;
191
198
}
192
199
193
200
void start () {
194
201
if (shards .isEmpty ()) {
195
202
listener .onResponse (new IndicesShardStoresResponse ());
196
203
} else {
197
204
for (Tuple <ShardId , String > shard : shards ) {
198
- InternalAsyncFetch fetch = new InternalAsyncFetch (logger , "shard_stores" , shard .v1 (), shard .v2 (), listShardStoresInfo );
205
+ InternalAsyncFetch fetch = new InternalAsyncFetch (
206
+ logger ,
207
+ "shard_stores" ,
208
+ shard .v1 (),
209
+ shard .v2 (),
210
+ listShardStoresInfo ,
211
+ clusterManagerMetrics
212
+ );
199
213
fetch .fetchData (nodes , Collections .emptyMap ());
200
214
}
201
215
}
@@ -213,9 +227,10 @@ private class InternalAsyncFetch extends AsyncShardFetch<NodeGatewayStartedShard
213
227
String type ,
214
228
ShardId shardId ,
215
229
String customDataPath ,
216
- TransportNodesListGatewayStartedShards action
230
+ TransportNodesListGatewayStartedShards action ,
231
+ ClusterManagerMetrics clusterManagerMetrics
217
232
) {
218
- super (logger , type , shardId , customDataPath , action );
233
+ super (logger , type , shardId , customDataPath , action , clusterManagerMetrics );
219
234
}
220
235
221
236
@ Override
0 commit comments