@@ -234,27 +234,18 @@ public ClusterState execute(ClusterState currentState) {
234
234
ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards =
235
235
shards (currentState , indexIds , useShardGenerations (version ), repositoryData );
236
236
if (request .partial () == false ) {
237
- Tuple <Set <String >, Set <String >> indicesWithMissingShards = indicesWithMissingShards (shards ,
238
- currentState .metadata ());
239
- Set <String > missing = indicesWithMissingShards .v1 ();
240
- Set <String > closed = indicesWithMissingShards .v2 ();
241
- if (missing .isEmpty () == false || closed .isEmpty () == false ) {
242
- final StringBuilder failureMessage = new StringBuilder ();
243
- if (missing .isEmpty () == false ) {
244
- failureMessage .append ("Indices don't have primary shards " );
245
- failureMessage .append (missing );
246
- }
247
- if (closed .isEmpty () == false ) {
248
- if (failureMessage .length () > 0 ) {
249
- failureMessage .append ("; " );
250
- }
251
- failureMessage .append ("Indices are closed " );
237
+ Set <String > missing = new HashSet <>();
238
+ for (ObjectObjectCursor <ShardId , SnapshotsInProgress .ShardSnapshotStatus > entry : shards ) {
239
+ if (entry .value .state () == ShardState .MISSING ) {
240
+ missing .add (entry .key .getIndex ().getName ());
252
241
}
242
+ }
243
+ if (missing .isEmpty () == false ) {
253
244
// TODO: We should just throw here instead of creating a FAILED and hence useless snapshot in the repository
254
245
newEntry = new SnapshotsInProgress .Entry (
255
246
new Snapshot (repositoryName , snapshotId ), request .includeGlobalState (), false ,
256
247
State .FAILED , indexIds , threadPool .absoluteTimeInMillis (), repositoryData .getGenId (), shards ,
257
- failureMessage . toString () , userMeta , version );
248
+ "Indices don't have primary shards " + missing , userMeta , version );
258
249
}
259
250
}
260
251
if (newEntry == null ) {
@@ -697,29 +688,6 @@ private static boolean removedNodesCleanupNeeded(SnapshotsInProgress snapshotsIn
697
688
.anyMatch (removedNodes .stream ().map (DiscoveryNode ::getId ).collect (Collectors .toSet ())::contains );
698
689
}
699
690
700
- /**
701
- * Returns list of indices with missing shards, and list of indices that are closed
702
- *
703
- * @param shards list of shard statuses
704
- * @return list of failed and closed indices
705
- */
706
- private static Tuple <Set <String >, Set <String >> indicesWithMissingShards (
707
- ImmutableOpenMap <ShardId , SnapshotsInProgress .ShardSnapshotStatus > shards , Metadata metadata ) {
708
- Set <String > missing = new HashSet <>();
709
- Set <String > closed = new HashSet <>();
710
- for (ObjectObjectCursor <ShardId , SnapshotsInProgress .ShardSnapshotStatus > entry : shards ) {
711
- if (entry .value .state () == ShardState .MISSING ) {
712
- if (metadata .hasIndex (entry .key .getIndex ().getName ()) &&
713
- metadata .getIndexSafe (entry .key .getIndex ()).getState () == IndexMetadata .State .CLOSE ) {
714
- closed .add (entry .key .getIndex ().getName ());
715
- } else {
716
- missing .add (entry .key .getIndex ().getName ());
717
- }
718
- }
719
- }
720
- return new Tuple <>(missing , closed );
721
- }
722
-
723
691
/**
724
692
* Finalizes the shard in repository and then removes it from cluster state
725
693
* <p>
0 commit comments