|
@@ -117,6 +117,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
(CancellableTask) task,
|
|
|
request.sort(),
|
|
|
request.after(),
|
|
|
+ request.offset(),
|
|
|
request.size(),
|
|
|
request.order(),
|
|
|
listener
|
|
@@ -133,6 +134,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
CancellableTask cancellableTask,
|
|
|
GetSnapshotsRequest.SortBy sortBy,
|
|
|
@Nullable GetSnapshotsRequest.After after,
|
|
|
+ int offset,
|
|
|
int size,
|
|
|
SortOrder order,
|
|
|
ActionListener<GetSnapshotsResponse> listener
|
|
@@ -154,7 +156,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
.map(Tuple::v1)
|
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toMap(Tuple::v1, Tuple::v2));
|
|
|
- final SnapshotsInRepo snInfos = sortSnapshots(allSnapshots, sortBy, after, size, order);
|
|
|
+ final SnapshotsInRepo snInfos = sortSnapshots(allSnapshots, sortBy, after, offset, size, order);
|
|
|
final List<SnapshotInfo> snapshotInfos = snInfos.snapshotInfos;
|
|
|
final int remaining = snInfos.remaining + responses.stream()
|
|
|
.map(Tuple::v2)
|
|
@@ -183,7 +185,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
cancellableTask,
|
|
|
sortBy,
|
|
|
after,
|
|
|
- size,
|
|
|
order,
|
|
|
groupedActionListener.delegateResponse((groupedListener, e) -> {
|
|
|
if (isMultiRepoRequest && e instanceof ElasticsearchException) {
|
|
@@ -205,7 +206,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
CancellableTask task,
|
|
|
GetSnapshotsRequest.SortBy sortBy,
|
|
|
@Nullable final GetSnapshotsRequest.After after,
|
|
|
- int size,
|
|
|
SortOrder order,
|
|
|
ActionListener<SnapshotsInRepo> listener
|
|
|
) {
|
|
@@ -237,7 +237,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
task,
|
|
|
sortBy,
|
|
|
after,
|
|
|
- size,
|
|
|
order,
|
|
|
listener
|
|
|
),
|
|
@@ -277,7 +276,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
CancellableTask task,
|
|
|
GetSnapshotsRequest.SortBy sortBy,
|
|
|
@Nullable final GetSnapshotsRequest.After after,
|
|
|
- int size,
|
|
|
SortOrder order,
|
|
|
ActionListener<SnapshotsInRepo> listener
|
|
|
) {
|
|
@@ -327,7 +325,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
task,
|
|
|
sortBy,
|
|
|
after,
|
|
|
- size,
|
|
|
order,
|
|
|
listener
|
|
|
);
|
|
@@ -335,14 +332,15 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
final SnapshotsInRepo snapshotInfos;
|
|
|
if (repositoryData != null) {
|
|
|
// want non-current snapshots as well, which are found in the repository data
|
|
|
- snapshotInfos = buildSimpleSnapshotInfos(toResolve, repo, repositoryData, currentSnapshots, sortBy, after, size, order);
|
|
|
+ snapshotInfos = buildSimpleSnapshotInfos(toResolve, repo, repositoryData, currentSnapshots, sortBy, after, order);
|
|
|
} else {
|
|
|
// only want current snapshots
|
|
|
snapshotInfos = sortSnapshots(
|
|
|
currentSnapshots.stream().map(SnapshotInfo::basic).collect(Collectors.toList()),
|
|
|
sortBy,
|
|
|
after,
|
|
|
- size,
|
|
|
+ 0,
|
|
|
+ GetSnapshotsRequest.NO_LIMIT,
|
|
|
order
|
|
|
);
|
|
|
}
|
|
@@ -365,7 +363,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
CancellableTask task,
|
|
|
GetSnapshotsRequest.SortBy sortBy,
|
|
|
@Nullable GetSnapshotsRequest.After after,
|
|
|
- int size,
|
|
|
SortOrder order,
|
|
|
ActionListener<SnapshotsInRepo> listener
|
|
|
) {
|
|
@@ -395,7 +392,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
final ActionListener<Void> allDoneListener = listener.delegateFailure((l, v) -> {
|
|
|
final ArrayList<SnapshotInfo> snapshotList = new ArrayList<>(snapshotInfos);
|
|
|
snapshotList.addAll(snapshotSet);
|
|
|
- listener.onResponse(sortSnapshots(snapshotList, sortBy, after, size, order));
|
|
|
+ listener.onResponse(sortSnapshots(snapshotList, sortBy, after, 0, GetSnapshotsRequest.NO_LIMIT, order));
|
|
|
});
|
|
|
if (snapshotIdsToIterate.isEmpty()) {
|
|
|
allDoneListener.onResponse(null);
|
|
@@ -445,7 +442,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
final List<SnapshotInfo> currentSnapshots,
|
|
|
final GetSnapshotsRequest.SortBy sortBy,
|
|
|
@Nullable final GetSnapshotsRequest.After after,
|
|
|
- final int size,
|
|
|
final SortOrder order
|
|
|
) {
|
|
|
List<SnapshotInfo> snapshotInfos = new ArrayList<>();
|
|
@@ -475,7 +471,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
)
|
|
|
);
|
|
|
}
|
|
|
- return sortSnapshots(snapshotInfos, sortBy, after, size, order);
|
|
|
+ return sortSnapshots(snapshotInfos, sortBy, after, 0, GetSnapshotsRequest.NO_LIMIT, order);
|
|
|
}
|
|
|
|
|
|
private static final Comparator<SnapshotInfo> BY_START_TIME = Comparator.comparingLong(SnapshotInfo::startTime)
|
|
@@ -494,6 +490,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
final List<SnapshotInfo> snapshotInfos,
|
|
|
final GetSnapshotsRequest.SortBy sortBy,
|
|
|
final @Nullable GetSnapshotsRequest.After after,
|
|
|
+ final int offset,
|
|
|
final int size,
|
|
|
final SortOrder order
|
|
|
) {
|
|
@@ -518,6 +515,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
Stream<SnapshotInfo> infos = snapshotInfos.stream();
|
|
|
|
|
|
if (after != null) {
|
|
|
+ assert offset == 0 : "can't combine after and offset but saw [" + after + "] and offset [" + offset + "]";
|
|
|
final Predicate<SnapshotInfo> isAfter;
|
|
|
final String snapshotName = after.snapshotName();
|
|
|
final String repoName = after.repoName();
|
|
@@ -553,7 +551,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|
|
}
|
|
|
infos = infos.filter(isAfter);
|
|
|
}
|
|
|
- infos = infos.sorted(order == SortOrder.DESC ? comparator.reversed() : comparator);
|
|
|
+ infos = infos.sorted(order == SortOrder.DESC ? comparator.reversed() : comparator).skip(offset);
|
|
|
final List<SnapshotInfo> allSnapshots = infos.collect(Collectors.toUnmodifiableList());
|
|
|
final List<SnapshotInfo> snapshots;
|
|
|
if (size != GetSnapshotsRequest.NO_LIMIT) {
|