Skip to content

Commit 0586cbf

Browse files
authored
Remove unused BlobStore#deleteBlobsIgnoringIfNotExists (#118245)
This method is never called against a general `BlobStore`, we only use it in certain implementations for which a bulk delete at the `BlobStore` level makes sense. This commit removes the unused interface method.
1 parent 22a392f commit 0586cbf

File tree

21 files changed

+17
-135
lines changed

21 files changed

+17
-135
lines changed

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
144144

145145
@Override
146146
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
147-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
147+
blobStore.deleteBlobs(purpose, new Iterator<>() {
148148
@Override
149149
public boolean hasNext() {
150150
return blobNames.hasNext();

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ public DeleteResult deleteBlobDirectory(OperationPurpose purpose, String path) t
264264
return new DeleteResult(blobsDeleted.get(), bytesDeleted.get());
265265
}
266266

267-
@Override
268-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
267+
void deleteBlobs(OperationPurpose purpose, Iterator<String> blobNames) {
269268
if (blobNames.hasNext() == false) {
270269
return;
271270
}

modules/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureBlobContainerStatsTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testRetriesAndOperationsAreTrackedSeparately() throws IOException {
7272
false
7373
);
7474
case LIST_BLOBS -> blobStore.listBlobsByPrefix(purpose, randomIdentifier(), randomIdentifier());
75-
case BLOB_BATCH -> blobStore.deleteBlobsIgnoringIfNotExists(
75+
case BLOB_BATCH -> blobStore.deleteBlobs(
7676
purpose,
7777
List.of(randomIdentifier(), randomIdentifier(), randomIdentifier()).iterator()
7878
);
@@ -113,7 +113,7 @@ public void testOperationPurposeIsReflectedInBlobStoreStats() throws IOException
113113
os.flush();
114114
});
115115
// BLOB_BATCH
116-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, List.of(randomIdentifier(), randomIdentifier(), randomIdentifier()).iterator());
116+
blobStore.deleteBlobs(purpose, List.of(randomIdentifier(), randomIdentifier(), randomIdentifier()).iterator());
117117

118118
Map<String, BlobStoreActionStats> stats = blobStore.stats();
119119
String statsMapString = stats.toString();
@@ -148,10 +148,7 @@ public void testOperationPurposeIsNotReflectedInBlobStoreStatsWhenNotServerless(
148148
os.flush();
149149
});
150150
// BLOB_BATCH
151-
blobStore.deleteBlobsIgnoringIfNotExists(
152-
purpose,
153-
List.of(randomIdentifier(), randomIdentifier(), randomIdentifier()).iterator()
154-
);
151+
blobStore.deleteBlobs(purpose, List.of(randomIdentifier(), randomIdentifier(), randomIdentifier()).iterator());
155152
}
156153

157154
Map<String, BlobStoreActionStats> stats = blobStore.stats();

modules/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe
114114

115115
@Override
116116
public DeleteResult delete(OperationPurpose purpose) throws IOException {
117-
return blobStore.deleteDirectory(purpose, path().buildAsString());
117+
return blobStore.deleteDirectory(path().buildAsString());
118118
}
119119

120120
@Override
121121
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
122-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
122+
blobStore.deleteBlobs(new Iterator<>() {
123123
@Override
124124
public boolean hasNext() {
125125
return blobNames.hasNext();

modules/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStore.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.elasticsearch.common.blobstore.BlobStore;
3030
import org.elasticsearch.common.blobstore.BlobStoreActionStats;
3131
import org.elasticsearch.common.blobstore.DeleteResult;
32-
import org.elasticsearch.common.blobstore.OperationPurpose;
3332
import org.elasticsearch.common.blobstore.OptionalBytesReference;
3433
import org.elasticsearch.common.blobstore.support.BlobContainerUtils;
3534
import org.elasticsearch.common.blobstore.support.BlobMetadata;
@@ -491,18 +490,17 @@ private void writeBlobMultipart(BlobInfo blobInfo, byte[] buffer, int offset, in
491490
/**
492491
* Deletes the given path and all its children.
493492
*
494-
* @param purpose The purpose of the delete operation
495493
* @param pathStr Name of path to delete
496494
*/
497-
DeleteResult deleteDirectory(OperationPurpose purpose, String pathStr) throws IOException {
495+
DeleteResult deleteDirectory(String pathStr) throws IOException {
498496
return SocketAccess.doPrivilegedIOException(() -> {
499497
DeleteResult deleteResult = DeleteResult.ZERO;
500498
Page<Blob> page = client().list(bucketName, BlobListOption.prefix(pathStr));
501499
do {
502500
final AtomicLong blobsDeleted = new AtomicLong(0L);
503501
final AtomicLong bytesDeleted = new AtomicLong(0L);
504502
final Iterator<Blob> blobs = page.getValues().iterator();
505-
deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
503+
deleteBlobs(new Iterator<>() {
506504
@Override
507505
public boolean hasNext() {
508506
return blobs.hasNext();
@@ -526,11 +524,9 @@ public String next() {
526524
/**
527525
* Deletes multiple blobs from the specific bucket using a batch request
528526
*
529-
* @param purpose the purpose of the delete operation
530527
* @param blobNames names of the blobs to delete
531528
*/
532-
@Override
533-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
529+
void deleteBlobs(Iterator<String> blobNames) throws IOException {
534530
if (blobNames.hasNext() == false) {
535531
return;
536532
}

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobContainer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
342342
return summary.getKey();
343343
});
344344
if (list.isTruncated()) {
345-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, blobNameIterator);
345+
blobStore.deleteBlobs(purpose, blobNameIterator);
346346
prevListing = list;
347347
} else {
348-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, Iterators.concat(blobNameIterator, Iterators.single(keyPath)));
348+
blobStore.deleteBlobs(purpose, Iterators.concat(blobNameIterator, Iterators.single(keyPath)));
349349
break;
350350
}
351351
}
@@ -357,7 +357,7 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
357357

358358
@Override
359359
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
360-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, Iterators.map(blobNames, this::buildKey));
360+
blobStore.deleteBlobs(purpose, Iterators.map(blobNames, this::buildKey));
361361
}
362362

363363
@Override

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobStore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ public BlobContainer blobContainer(BlobPath path) {
340340
return new S3BlobContainer(path, this);
341341
}
342342

343-
@Override
344-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
343+
void deleteBlobs(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
345344
if (blobNames.hasNext() == false) {
346345
return;
347346
}

modules/repository-url/src/main/java/org/elasticsearch/common/blobstore/url/URLBlobStore.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.common.blobstore.BlobPath;
1414
import org.elasticsearch.common.blobstore.BlobStore;
1515
import org.elasticsearch.common.blobstore.BlobStoreException;
16-
import org.elasticsearch.common.blobstore.OperationPurpose;
1716
import org.elasticsearch.common.blobstore.url.http.HttpURLBlobContainer;
1817
import org.elasticsearch.common.blobstore.url.http.URLHttpClient;
1918
import org.elasticsearch.common.blobstore.url.http.URLHttpClientSettings;
@@ -23,10 +22,8 @@
2322
import org.elasticsearch.common.unit.ByteSizeValue;
2423
import org.elasticsearch.core.CheckedFunction;
2524

26-
import java.io.IOException;
2725
import java.net.MalformedURLException;
2826
import java.net.URL;
29-
import java.util.Iterator;
3027
import java.util.List;
3128

3229
/**
@@ -109,11 +106,6 @@ public BlobContainer blobContainer(BlobPath blobPath) {
109106
}
110107
}
111108

112-
@Override
113-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
114-
throw new UnsupportedOperationException("Bulk deletes are not supported in URL repositories");
115-
}
116-
117109
@Override
118110
public void close() {
119111
// nothing to do here...

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobStore.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
import org.elasticsearch.common.blobstore.BlobContainer;
1717
import org.elasticsearch.common.blobstore.BlobPath;
1818
import org.elasticsearch.common.blobstore.BlobStore;
19-
import org.elasticsearch.common.blobstore.OperationPurpose;
2019

2120
import java.io.IOException;
22-
import java.util.Iterator;
2321

2422
final class HdfsBlobStore implements BlobStore {
2523

@@ -72,11 +70,6 @@ public BlobContainer blobContainer(BlobPath path) {
7270
return new HdfsBlobContainer(path, this, buildHdfsPath(path), bufferSize, securityContext, replicationFactor);
7371
}
7472

75-
@Override
76-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
77-
throw new UnsupportedOperationException("Bulk deletes are not supported in Hdfs repositories");
78-
}
79-
8073
private Path buildHdfsPath(BlobPath blobPath) {
8174
final Path path = translateToHdfsPath(blobPath);
8275
if (readOnly == false) {

plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsBlobStoreRepositoryTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public void testSnapshotAndRestore() throws Exception {
4646
testSnapshotAndRestore(false);
4747
}
4848

49-
@Override
50-
public void testBlobStoreBulkDeletion() throws Exception {
51-
// HDFS does not implement bulk deletion from different BlobContainers
52-
}
53-
5449
@Override
5550
protected Collection<Class<? extends Plugin>> nodePlugins() {
5651
return Collections.singletonList(HdfsPlugin.class);

0 commit comments

Comments
 (0)