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
This commit is contained in:
Armin Braun 2019-07-12 15:03:09 +02:00 committed by GitHub
parent 068286ca4b
commit 9b4f50b40a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 11 deletions

View File

@ -94,7 +94,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
final RepositoryData repositoryData;
if (isCurrentSnapshotsOnly(request.snapshots()) == false) {
repositoryData = snapshotsService.getRepositoryData(repository);
for (SnapshotId snapshotId : repositoryData.getAllSnapshotIds()) {
for (SnapshotId snapshotId : repositoryData.getSnapshotIds()) {
allSnapshotIds.put(snapshotId.getName(), snapshotId);
}
} else {

View File

@ -194,7 +194,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
if (Strings.hasText(repositoryName) && request.snapshots() != null && request.snapshots().length > 0) {
final Set<String> requestedSnapshotNames = Sets.newHashSet(request.snapshots());
final RepositoryData repositoryData = snapshotsService.getRepositoryData(repositoryName);
final Map<String, SnapshotId> matchedSnapshotIds = repositoryData.getAllSnapshotIds().stream()
final Map<String, SnapshotId> matchedSnapshotIds = repositoryData.getSnapshotIds().stream()
.filter(s -> requestedSnapshotNames.contains(s.getName()))
.collect(Collectors.toMap(SnapshotId::getName, Function.identity()));
for (final String snapshotName : request.snapshots()) {

View File

@ -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<SnapshotId> 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.

View File

@ -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<String> rootBlobNames, RepositoryData repositoryData) {
final Set<String> allSnapshotIds =
repositoryData.getAllSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet());
repositoryData.getSnapshotIds().stream().map(SnapshotId::getUUID).collect(Collectors.toSet());
final List<String> blobsToDelete = rootBlobNames.stream().filter(
blob -> {
if (FsBlobContainer.isTempBlobName(blob)) {