Skip to content

Commit c31ec17

Browse files
committed
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 20dc928 commit c31ec17

File tree

20 files changed

+14
-130
lines changed

20 files changed

+14
-130
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
@@ -134,7 +134,7 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
134134

135135
@Override
136136
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
137-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
137+
blobStore.deleteBlobs(new Iterator<>() {
138138
@Override
139139
public boolean hasNext() {
140140
return blobNames.hasNext();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.elasticsearch.common.blobstore.BlobPath;
4848
import org.elasticsearch.common.blobstore.BlobStore;
4949
import org.elasticsearch.common.blobstore.DeleteResult;
50-
import org.elasticsearch.common.blobstore.OperationPurpose;
5150
import org.elasticsearch.common.blobstore.OptionalBytesReference;
5251
import org.elasticsearch.common.blobstore.support.BlobContainerUtils;
5352
import org.elasticsearch.common.blobstore.support.BlobMetadata;
@@ -265,8 +264,7 @@ private static void filterDeleteExceptionsAndRethrow(Exception e, IOException ex
265264
throw exception;
266265
}
267266

268-
@Override
269-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobs) throws IOException {
267+
void deleteBlobs(Iterator<String> blobs) throws IOException {
270268
if (blobs.hasNext() == false) {
271269
return;
272270
}

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
@@ -103,12 +103,12 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe
103103

104104
@Override
105105
public DeleteResult delete(OperationPurpose purpose) throws IOException {
106-
return blobStore.deleteDirectory(purpose, path().buildAsString());
106+
return blobStore.deleteDirectory(path().buildAsString());
107107
}
108108

109109
@Override
110110
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
111-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
111+
blobStore.deleteBlobs(new Iterator<>() {
112112
@Override
113113
public boolean hasNext() {
114114
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
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.common.blobstore.BlobPath;
2929
import org.elasticsearch.common.blobstore.BlobStore;
3030
import org.elasticsearch.common.blobstore.DeleteResult;
31-
import org.elasticsearch.common.blobstore.OperationPurpose;
3231
import org.elasticsearch.common.blobstore.OptionalBytesReference;
3332
import org.elasticsearch.common.blobstore.support.BlobContainerUtils;
3433
import org.elasticsearch.common.blobstore.support.BlobMetadata;
@@ -490,18 +489,17 @@ private void writeBlobMultipart(BlobInfo blobInfo, byte[] buffer, int offset, in
490489
/**
491490
* Deletes the given path and all its children.
492491
*
493-
* @param purpose The purpose of the delete operation
494492
* @param pathStr Name of path to delete
495493
*/
496-
DeleteResult deleteDirectory(OperationPurpose purpose, String pathStr) throws IOException {
494+
DeleteResult deleteDirectory(String pathStr) throws IOException {
497495
return SocketAccess.doPrivilegedIOException(() -> {
498496
DeleteResult deleteResult = DeleteResult.ZERO;
499497
Page<Blob> page = client().list(bucketName, BlobListOption.prefix(pathStr));
500498
do {
501499
final AtomicLong blobsDeleted = new AtomicLong(0L);
502500
final AtomicLong bytesDeleted = new AtomicLong(0L);
503501
final Iterator<Blob> blobs = page.getValues().iterator();
504-
deleteBlobsIgnoringIfNotExists(purpose, new Iterator<>() {
502+
deleteBlobs(new Iterator<>() {
505503
@Override
506504
public boolean hasNext() {
507505
return blobs.hasNext();
@@ -525,11 +523,9 @@ public String next() {
525523
/**
526524
* Deletes multiple blobs from the specific bucket using a batch request
527525
*
528-
* @param purpose the purpose of the delete operation
529526
* @param blobNames names of the blobs to delete
530527
*/
531-
@Override
532-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
528+
void deleteBlobs(Iterator<String> blobNames) throws IOException {
533529
if (blobNames.hasNext() == false) {
534530
return;
535531
}

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
@@ -329,10 +329,10 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
329329
return summary.getKey();
330330
});
331331
if (list.isTruncated()) {
332-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, blobNameIterator);
332+
blobStore.deleteBlobs(purpose, blobNameIterator);
333333
prevListing = list;
334334
} else {
335-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, Iterators.concat(blobNameIterator, Iterators.single(keyPath)));
335+
blobStore.deleteBlobs(purpose, Iterators.concat(blobNameIterator, Iterators.single(keyPath)));
336336
break;
337337
}
338338
}
@@ -344,7 +344,7 @@ public DeleteResult delete(OperationPurpose purpose) throws IOException {
344344

345345
@Override
346346
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
347-
blobStore.deleteBlobsIgnoringIfNotExists(purpose, Iterators.map(blobNames, this::buildKey));
347+
blobStore.deleteBlobs(purpose, Iterators.map(blobNames, this::buildKey));
348348
}
349349

350350
@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
@@ -332,8 +332,7 @@ public BlobContainer blobContainer(BlobPath path) {
332332
return new S3BlobContainer(path, this);
333333
}
334334

335-
@Override
336-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
335+
void deleteBlobs(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
337336
if (blobNames.hasNext() == false) {
338337
return;
339338
}

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

server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryOperationPurposeIT.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.io.InputStream;
3737
import java.io.OutputStream;
3838
import java.util.Collection;
39-
import java.util.Iterator;
4039
import java.util.Map;
4140
import java.util.concurrent.TimeUnit;
4241

@@ -136,11 +135,6 @@ public BlobContainer blobContainer(BlobPath path) {
136135
return new AssertingBlobContainer(delegateBlobStore.blobContainer(path));
137136
}
138137

139-
@Override
140-
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException {
141-
delegateBlobStore.deleteBlobsIgnoringIfNotExists(purpose, blobNames);
142-
}
143-
144138
@Override
145139
public void close() throws IOException {
146140
delegateBlobStore.close();

0 commit comments

Comments
 (0)