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)) {