@@ -151,7 +151,7 @@ protected void clusterManagerOperation(
151151 final ClusterState state ,
152152 final ActionListener <SnapshotsStatusResponse > listener
153153 ) throws Exception {
154- requestSetup (request );
154+ setupForRequest (request );
155155
156156 final SnapshotsInProgress snapshotsInProgress = state .custom (SnapshotsInProgress .TYPE , SnapshotsInProgress .EMPTY );
157157 List <SnapshotsInProgress .Entry > currentSnapshots = SnapshotsService .currentSnapshots (
@@ -193,21 +193,21 @@ protected void clusterManagerOperation(
193193
194194 }
195195
196- private void requestSetup (SnapshotsStatusRequest request ) {
196+ private void setupForRequest (SnapshotsStatusRequest request ) {
197197 requestedIndexNames = new HashSet <>(Arrays .asList (request .indices ()));
198198 requestUsesIndexFilter = requestedIndexNames .isEmpty () == false ;
199199 totalShardsRequiredInResponse = 0 ;
200200 maximumAllowedShardCount = clusterService .getClusterSettings ().get (MAX_SHARDS_ALLOWED_IN_STATUS_API );
201201 }
202202
203-
204203 /*
205204 * To get the node IDs of the relevant (according to the index filter) shards which are part of current snapshots
206205 * It also deals with any missing indices (for index-filter case) and calculates the number of shards contributed by all
207206 * the current snapshots to the total count (irrespective of index-filter)
208207 * If this count exceeds the limit, CircuitBreakingException is thrown
209208 * */
210- private Set <String > getNodeIdsOfCurrentSnapshots (final SnapshotsStatusRequest request , List <SnapshotsInProgress .Entry > currentSnapshots ) throws CircuitBreakingException {
209+ private Set <String > getNodeIdsOfCurrentSnapshots (final SnapshotsStatusRequest request , List <SnapshotsInProgress .Entry > currentSnapshots )
210+ throws CircuitBreakingException {
211211 Set <String > nodesIdsOfCurrentSnapshotShards = new HashSet <>();
212212 int totalShardsAcrossCurrentSnapshots = 0 ;
213213
@@ -217,7 +217,8 @@ private Set<String> getNodeIdsOfCurrentSnapshots(final SnapshotsStatusRequest re
217217 // index-filter is allowed only for a single snapshot, which has to be this one
218218 // first check if any requested indices are missing from this current snapshot
219219
220- final Set <String > indicesInCurrentSnapshot = currentSnapshotEntry .indices ().stream ()
220+ final Set <String > indicesInCurrentSnapshot = currentSnapshotEntry .indices ()
221+ .stream ()
221222 .map (IndexId ::getName )
222223 .collect (Collectors .toSet ());
223224
@@ -226,15 +227,22 @@ private Set<String> getNodeIdsOfCurrentSnapshots(final SnapshotsStatusRequest re
226227 .collect (Collectors .toSet ());
227228
228229 if (indicesNotFound .isEmpty () == false ) {
229- handleIndexNotFound (requestedIndexNames , indicesNotFound , request , currentSnapshotEntry .snapshot ().getSnapshotId ().getName (), false );
230+ handleIndexNotFound (
231+ requestedIndexNames ,
232+ indicesNotFound ,
233+ request ,
234+ currentSnapshotEntry .snapshot ().getSnapshotId ().getName (),
235+ false
236+ );
230237 }
231238 // the actual no. of shards contributed by this current snapshot will now be calculated
232239 } else {
233240 // all shards of this current snapshot are required in response
234241 totalShardsAcrossCurrentSnapshots = currentSnapshotEntry .shards ().size ();
235242 }
236243
237- for (final Map .Entry <ShardId , SnapshotsInProgress .ShardSnapshotStatus > shardStatusEntry : currentSnapshotEntry .shards ().entrySet ()) {
244+ for (final Map .Entry <ShardId , SnapshotsInProgress .ShardSnapshotStatus > shardStatusEntry : currentSnapshotEntry .shards ()
245+ .entrySet ()) {
238246 SnapshotsInProgress .ShardSnapshotStatus shardStatus = shardStatusEntry .getValue ();
239247 boolean indexPresentInFilter = requestedIndexNames .contains (shardStatusEntry .getKey ().getIndexName ());
240248
@@ -261,7 +269,8 @@ private Set<String> getNodeIdsOfCurrentSnapshots(final SnapshotsStatusRequest re
261269 // index-filter is allowed only for a single snapshot. If index-filter is being used and limit got exceeded,
262270 // this snapshot is current and its relevant indices contribute more shards than the limit
263271
264- // if index-filter is not being used and limit got exceed, there could be more shards required in response coming from completed snapshots
272+ // if index-filter is not being used and limit got exceed, there could be more shards required in response coming from completed
273+ // snapshots
265274 // but since the limit is already exceeded, we can fail request here
266275 boolean couldInvolveMoreShards = requestUsesIndexFilter == false ;
267276 handleMaximumAllowedShardCountExceeded (request .repository (), totalShardsRequiredInResponse , couldInvolveMoreShards );
@@ -669,16 +678,28 @@ private void handleIndexNotFound(
669678 // remove unavailable indices from the set to be processed
670679 indicesToProcess .removeAll (indicesNotFound );
671680 } else {
672- String cause = "indices [" + indices + "] missing in snapshot [" + snapshotName + "] of repository [" + request .repository () + "]" ;
681+ String cause = "indices ["
682+ + indices
683+ + "] missing in snapshot ["
684+ + snapshotName
685+ + "] of repository ["
686+ + request .repository ()
687+ + "]" ;
673688 throw new IndexNotFoundException (indices , new IllegalArgumentException (cause ));
674689 }
675690 }
676691
677- private void handleMaximumAllowedShardCountExceeded (String repositoryName , int totalContributingShards , boolean couldInvolveMoreShards ) throws CircuitBreakingException {
692+ private void handleMaximumAllowedShardCountExceeded (String repositoryName , int totalContributingShards , boolean couldInvolveMoreShards )
693+ throws CircuitBreakingException {
678694 String shardCount = "[" + totalContributingShards + (couldInvolveMoreShards ? "+" : "" ) + "]" ;
679- String message = "[" + repositoryName + "] Total shard count " + shardCount + " is more than the maximum allowed value of shard count [" +
680- maximumAllowedShardCount + "] for snapshot status request. Try narrowing down the request by using a snapshot list or " +
681- "an index list for a singular snapshot." ;
695+ String message = "["
696+ + repositoryName
697+ + "] Total shard count "
698+ + shardCount
699+ + " is more than the maximum allowed value of shard count ["
700+ + maximumAllowedShardCount
701+ + "] for snapshot status request. Try narrowing down the request by using a snapshot list or "
702+ + "an index list for a singular snapshot." ;
682703
683704 throw new CircuitBreakingException (message , CircuitBreaker .Durability .PERMANENT );
684705 }
0 commit comments