@@ -46,6 +46,8 @@ public class GetSnapshotsRequest extends MasterNodeRequest<GetSnapshotsRequest>
46
46
47
47
public static final Version NUMERIC_PAGINATION_VERSION = Version .V_7_15_0 ;
48
48
49
+ private static final Version SORT_BY_SHARD_COUNTS_VERSION = Version .V_7_16_0 ;
50
+
49
51
public static final int NO_LIMIT = -1 ;
50
52
51
53
/**
@@ -147,6 +149,9 @@ public void writeTo(StreamOutput out) throws IOException {
147
149
out .writeBoolean (verbose );
148
150
if (out .getVersion ().onOrAfter (PAGINATED_GET_SNAPSHOTS_VERSION )) {
149
151
out .writeOptionalWriteable (after );
152
+ if ((sort == SortBy .SHARDS || sort == SortBy .FAILED_SHARDS ) && out .getVersion ().before (SORT_BY_SHARD_COUNTS_VERSION )) {
153
+ throw new IllegalArgumentException ("can't use sort by shard count with node version [" + out .getVersion () + "]" );
154
+ }
150
155
out .writeEnum (sort );
151
156
out .writeVInt (size );
152
157
order .writeTo (out );
@@ -356,7 +361,9 @@ public enum SortBy {
356
361
START_TIME ("start_time" ),
357
362
NAME ("name" ),
358
363
DURATION ("duration" ),
359
- INDICES ("index_count" );
364
+ INDICES ("index_count" ),
365
+ SHARDS ("shard_count" ),
366
+ FAILED_SHARDS ("failed_shard_count" );
360
367
361
368
private final String param ;
362
369
@@ -379,6 +386,10 @@ public static SortBy of(String value) {
379
386
return DURATION ;
380
387
case "index_count" :
381
388
return INDICES ;
389
+ case "shard_count" :
390
+ return SHARDS ;
391
+ case "failed_shard_count" :
392
+ return FAILED_SHARDS ;
382
393
default :
383
394
throw new IllegalArgumentException ("unknown sort order [" + value + "]" );
384
395
}
@@ -424,6 +435,12 @@ public static After from(@Nullable SnapshotInfo snapshotInfo, SortBy sortBy) {
424
435
case INDICES :
425
436
afterValue = String .valueOf (snapshotInfo .indices ().size ());
426
437
break ;
438
+ case SHARDS :
439
+ afterValue = String .valueOf (snapshotInfo .totalShards ());
440
+ break ;
441
+ case FAILED_SHARDS :
442
+ afterValue = String .valueOf (snapshotInfo .failedShards ());
443
+ break ;
427
444
default :
428
445
throw new AssertionError ("unknown sort column [" + sortBy + "]" );
429
446
}
0 commit comments