From 9b4f50b40a82f4f9ca8e4a18e30337064dd2abb9 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Fri, 12 Jul 2019 15:03:09 +0200 Subject: [PATCH] Remove Redundant GetAllSnapshots Method from RepositoryData (#44259) (#44271) * With the removal of the incompatible snapshots list in RepositoryData the get snapshots and get all snapshots methods are equivalent so I removed one of them --- .../cluster/snapshots/get/TransportGetSnapshotsAction.java | 2 +- .../snapshots/status/TransportSnapshotsStatusAction.java | 2 +- .../org/elasticsearch/repositories/RepositoryData.java | 7 ------- .../repositories/blobstore/BlobStoreRepository.java | 4 ++-- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java index fe155bb8394..86bbfa5f102 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java @@ -94,7 +94,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction 0) { final Set requestedSnapshotNames = Sets.newHashSet(request.snapshots()); final RepositoryData repositoryData = snapshotsService.getRepositoryData(repositoryName); - final Map matchedSnapshotIds = repositoryData.getAllSnapshotIds().stream() + final Map matchedSnapshotIds = repositoryData.getSnapshotIds().stream() .filter(s -> requestedSnapshotNames.contains(s.getName())) .collect(Collectors.toMap(SnapshotId::getName, Function.identity())); for (final String snapshotName : request.snapshots()) { diff --git a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java index df18bdba8e6..7d4df49aeaf 100644 --- a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java +++ b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java @@ -107,13 +107,6 @@ public final class RepositoryData { return Collections.unmodifiableCollection(snapshotIds.values()); } - /** - * Returns an immutable collection of all the snapshot ids in the repository. - */ - public Collection getAllSnapshotIds() { - return new ArrayList<>(snapshotIds.values()); - } - /** * Returns the {@link SnapshotState} for the given snapshot. Returns {@code null} if * there is no state for the snapshot. diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index e4ba20e37d0..62707eb9964 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -388,7 +388,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp final String snapshotName = snapshotId.getName(); // check if the snapshot name already exists in the repository final RepositoryData repositoryData = getRepositoryData(); - if (repositoryData.getAllSnapshotIds().stream().anyMatch(s -> s.getName().equals(snapshotName))) { + if (repositoryData.getSnapshotIds().stream().anyMatch(s -> s.getName().equals(snapshotName))) { throw new InvalidSnapshotNameException(metadata.name(), snapshotId.getName(), "snapshot with the same name already exists"); } @@ -460,7 +460,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp private void cleanupStaleRootFiles(Set rootBlobNames, RepositoryData repositoryData) { final Set allSnapshotIds = - repositoryData.getAllSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet()); + repositoryData.getSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet()); final List blobsToDelete = rootBlobNames.stream().filter( blob -> { if (FsBlobContainer.isTempBlobName(blob)) {