@@ -117,6 +117,7 @@ protected void masterOperation(
117
117
(CancellableTask ) task ,
118
118
request .sort (),
119
119
request .after (),
120
+ request .offset (),
120
121
request .size (),
121
122
request .order (),
122
123
listener
@@ -133,6 +134,7 @@ private void getMultipleReposSnapshotInfo(
133
134
CancellableTask cancellableTask ,
134
135
GetSnapshotsRequest .SortBy sortBy ,
135
136
@ Nullable GetSnapshotsRequest .After after ,
137
+ int offset ,
136
138
int size ,
137
139
SortOrder order ,
138
140
ActionListener <GetSnapshotsResponse > listener
@@ -154,7 +156,7 @@ private void getMultipleReposSnapshotInfo(
154
156
.map (Tuple ::v1 )
155
157
.filter (Objects ::nonNull )
156
158
.collect (Collectors .toMap (Tuple ::v1 , Tuple ::v2 ));
157
- final SnapshotsInRepo snInfos = sortSnapshots (allSnapshots , sortBy , after , size , order );
159
+ final SnapshotsInRepo snInfos = sortSnapshots (allSnapshots , sortBy , after , offset , size , order );
158
160
final List <SnapshotInfo > snapshotInfos = snInfos .snapshotInfos ;
159
161
final int remaining = snInfos .remaining + responses .stream ()
160
162
.map (Tuple ::v2 )
@@ -183,7 +185,6 @@ private void getMultipleReposSnapshotInfo(
183
185
cancellableTask ,
184
186
sortBy ,
185
187
after ,
186
- size ,
187
188
order ,
188
189
groupedActionListener .delegateResponse ((groupedListener , e ) -> {
189
190
if (isMultiRepoRequest && e instanceof ElasticsearchException ) {
@@ -205,7 +206,6 @@ private void getSingleRepoSnapshotInfo(
205
206
CancellableTask task ,
206
207
GetSnapshotsRequest .SortBy sortBy ,
207
208
@ Nullable final GetSnapshotsRequest .After after ,
208
- int size ,
209
209
SortOrder order ,
210
210
ActionListener <SnapshotsInRepo > listener
211
211
) {
@@ -237,7 +237,6 @@ private void getSingleRepoSnapshotInfo(
237
237
task ,
238
238
sortBy ,
239
239
after ,
240
- size ,
241
240
order ,
242
241
listener
243
242
),
@@ -277,7 +276,6 @@ private void loadSnapshotInfos(
277
276
CancellableTask task ,
278
277
GetSnapshotsRequest .SortBy sortBy ,
279
278
@ Nullable final GetSnapshotsRequest .After after ,
280
- int size ,
281
279
SortOrder order ,
282
280
ActionListener <SnapshotsInRepo > listener
283
281
) {
@@ -327,22 +325,22 @@ private void loadSnapshotInfos(
327
325
task ,
328
326
sortBy ,
329
327
after ,
330
- size ,
331
328
order ,
332
329
listener
333
330
);
334
331
} else {
335
332
final SnapshotsInRepo snapshotInfos ;
336
333
if (repositoryData != null ) {
337
334
// want non-current snapshots as well, which are found in the repository data
338
- snapshotInfos = buildSimpleSnapshotInfos (toResolve , repo , repositoryData , currentSnapshots , sortBy , after , size , order );
335
+ snapshotInfos = buildSimpleSnapshotInfos (toResolve , repo , repositoryData , currentSnapshots , sortBy , after , order );
339
336
} else {
340
337
// only want current snapshots
341
338
snapshotInfos = sortSnapshots (
342
339
currentSnapshots .stream ().map (SnapshotInfo ::basic ).collect (Collectors .toList ()),
343
340
sortBy ,
344
341
after ,
345
- size ,
342
+ 0 ,
343
+ GetSnapshotsRequest .NO_LIMIT ,
346
344
order
347
345
);
348
346
}
@@ -365,7 +363,6 @@ private void snapshots(
365
363
CancellableTask task ,
366
364
GetSnapshotsRequest .SortBy sortBy ,
367
365
@ Nullable GetSnapshotsRequest .After after ,
368
- int size ,
369
366
SortOrder order ,
370
367
ActionListener <SnapshotsInRepo > listener
371
368
) {
@@ -395,7 +392,7 @@ private void snapshots(
395
392
final ActionListener <Void > allDoneListener = listener .delegateFailure ((l , v ) -> {
396
393
final ArrayList <SnapshotInfo > snapshotList = new ArrayList <>(snapshotInfos );
397
394
snapshotList .addAll (snapshotSet );
398
- listener .onResponse (sortSnapshots (snapshotList , sortBy , after , size , order ));
395
+ listener .onResponse (sortSnapshots (snapshotList , sortBy , after , 0 , GetSnapshotsRequest . NO_LIMIT , order ));
399
396
});
400
397
if (snapshotIdsToIterate .isEmpty ()) {
401
398
allDoneListener .onResponse (null );
@@ -445,7 +442,6 @@ private static SnapshotsInRepo buildSimpleSnapshotInfos(
445
442
final List <SnapshotInfo > currentSnapshots ,
446
443
final GetSnapshotsRequest .SortBy sortBy ,
447
444
@ Nullable final GetSnapshotsRequest .After after ,
448
- final int size ,
449
445
final SortOrder order
450
446
) {
451
447
List <SnapshotInfo > snapshotInfos = new ArrayList <>();
@@ -475,7 +471,7 @@ private static SnapshotsInRepo buildSimpleSnapshotInfos(
475
471
)
476
472
);
477
473
}
478
- return sortSnapshots (snapshotInfos , sortBy , after , size , order );
474
+ return sortSnapshots (snapshotInfos , sortBy , after , 0 , GetSnapshotsRequest . NO_LIMIT , order );
479
475
}
480
476
481
477
private static final Comparator <SnapshotInfo > BY_START_TIME = Comparator .comparingLong (SnapshotInfo ::startTime )
@@ -494,6 +490,7 @@ private static SnapshotsInRepo sortSnapshots(
494
490
final List <SnapshotInfo > snapshotInfos ,
495
491
final GetSnapshotsRequest .SortBy sortBy ,
496
492
final @ Nullable GetSnapshotsRequest .After after ,
493
+ final int offset ,
497
494
final int size ,
498
495
final SortOrder order
499
496
) {
@@ -518,6 +515,7 @@ private static SnapshotsInRepo sortSnapshots(
518
515
Stream <SnapshotInfo > infos = snapshotInfos .stream ();
519
516
520
517
if (after != null ) {
518
+ assert offset == 0 : "can't combine after and offset but saw [" + after + "] and offset [" + offset + "]" ;
521
519
final Predicate <SnapshotInfo > isAfter ;
522
520
final String snapshotName = after .snapshotName ();
523
521
final String repoName = after .repoName ();
@@ -553,7 +551,7 @@ private static SnapshotsInRepo sortSnapshots(
553
551
}
554
552
infos = infos .filter (isAfter );
555
553
}
556
- infos = infos .sorted (order == SortOrder .DESC ? comparator .reversed () : comparator );
554
+ infos = infos .sorted (order == SortOrder .DESC ? comparator .reversed () : comparator ). skip ( offset ) ;
557
555
final List <SnapshotInfo > allSnapshots = infos .collect (Collectors .toUnmodifiableList ());
558
556
final List <SnapshotInfo > snapshots ;
559
557
if (size != GetSnapshotsRequest .NO_LIMIT ) {
0 commit comments