From 1c86da0fa4119d32f5eaaa61fe26291335dd5175 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Tue, 3 Oct 2023 23:32:56 +1100 Subject: [PATCH] Remove deprecated methods from BlobStore and BlobContainer (#100177) All their usages have been replaced by corresponding new versions. Relates: #99615 --- .../common/blobstore/BlobContainer.java | 85 ------------------- .../common/blobstore/BlobStore.java | 15 +--- .../blobstore/BlobStoreRepository.java | 1 + 3 files changed, 2 insertions(+), 99 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java b/server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java index ce4d249b2e112..c832f222ecc69 100644 --- a/server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java +++ b/server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java @@ -43,11 +43,6 @@ public interface BlobContainer { */ boolean blobExists(OperationPurpose purpose, String blobName) throws IOException; - @Deprecated(forRemoval = true) - default boolean blobExists(String blobName) throws IOException { - return blobExists(OperationPurpose.SNAPSHOT, blobName); - } - /** * Creates a new {@link InputStream} for the given blob name. * @@ -59,11 +54,6 @@ default boolean blobExists(String blobName) throws IOException { */ InputStream readBlob(OperationPurpose purpose, String blobName) throws IOException; - @Deprecated(forRemoval = true) - default InputStream readBlob(String blobName) throws IOException { - return readBlob(OperationPurpose.SNAPSHOT, blobName); - } - /** * Creates a new {@link InputStream} that can be used to read the given blob starting from * a specific {@code position} in the blob. The {@code length} is an indication of the @@ -79,11 +69,6 @@ default InputStream readBlob(String blobName) throws IOException { */ InputStream readBlob(OperationPurpose purpose, String blobName, long position, long length) throws IOException; - @Deprecated(forRemoval = true) - default InputStream readBlob(String blobName, long position, long length) throws IOException { - return readBlob(OperationPurpose.SNAPSHOT, blobName, position, length); - } - /** * Provides a hint to clients for a suitable length to use with {@link BlobContainer#readBlob(OperationPurpose, String, long, long)}. * @@ -119,11 +104,6 @@ default long readBlobPreferredLength() { void writeBlob(OperationPurpose purpose, String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws IOException; - @Deprecated(forRemoval = true) - default void writeBlob(String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws IOException { - writeBlob(OperationPurpose.SNAPSHOT, blobName, inputStream, blobSize, failIfAlreadyExists); - } - /** * Reads blob content from a {@link BytesReference} and writes it to the container in a new blob with the given name. * @@ -139,11 +119,6 @@ default void writeBlob(OperationPurpose purpose, String blobName, BytesReference writeBlob(purpose, blobName, bytes.streamInput(), bytes.length(), failIfAlreadyExists); } - @Deprecated(forRemoval = true) - default void writeBlob(String blobName, BytesReference bytes, boolean failIfAlreadyExists) throws IOException { - writeBlob(OperationPurpose.SNAPSHOT, blobName, bytes, failIfAlreadyExists); - } - /** * Write a blob by providing a consumer that will write its contents to an output stream. This method allows serializing a blob's * contents directly to the blob store without having to materialize the serialized version in full before writing. @@ -164,16 +139,6 @@ void writeMetadataBlob( CheckedConsumer writer ) throws IOException; - @Deprecated(forRemoval = true) - default void writeMetadataBlob( - String blobName, - boolean failIfAlreadyExists, - boolean atomic, - CheckedConsumer writer - ) throws IOException { - writeMetadataBlob(OperationPurpose.SNAPSHOT, blobName, failIfAlreadyExists, atomic, writer); - } - /** * Reads blob content from a {@link BytesReference} and writes it to the container in a new blob with the given name, * using an atomic write operation if the implementation supports it. @@ -187,11 +152,6 @@ default void writeMetadataBlob( */ void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesReference bytes, boolean failIfAlreadyExists) throws IOException; - @Deprecated(forRemoval = true) - default void writeBlobAtomic(String blobName, BytesReference bytes, boolean failIfAlreadyExists) throws IOException { - writeBlobAtomic(OperationPurpose.SNAPSHOT, blobName, bytes, failIfAlreadyExists); - } - /** * Deletes this container and all its contents from the repository. * @@ -201,11 +161,6 @@ default void writeBlobAtomic(String blobName, BytesReference bytes, boolean fail */ DeleteResult delete(OperationPurpose purpose) throws IOException; - @Deprecated(forRemoval = true) - default DeleteResult delete() throws IOException { - return delete(OperationPurpose.SNAPSHOT); - } - /** * Deletes the blobs with given names. This method will not throw an exception * when one or multiple of the given blobs don't exist and simply ignore this case. @@ -216,11 +171,6 @@ default DeleteResult delete() throws IOException { */ void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator blobNames) throws IOException; - @Deprecated(forRemoval = true) - default void deleteBlobsIgnoringIfNotExists(Iterator blobNames) throws IOException { - deleteBlobsIgnoringIfNotExists(OperationPurpose.SNAPSHOT, blobNames); - } - /** * Lists all blobs in the container. * @@ -230,11 +180,6 @@ default void deleteBlobsIgnoringIfNotExists(Iterator blobNames) throws I */ Map listBlobs(OperationPurpose purpose) throws IOException; - @Deprecated(forRemoval = true) - default Map listBlobs() throws IOException { - return listBlobs(OperationPurpose.SNAPSHOT); - } - /** * Lists all child containers under this container. A child container is defined as a container whose {@link #path()} method returns * a path that has this containers {@link #path()} return as its prefix and has one more path element than the current @@ -246,11 +191,6 @@ default Map listBlobs() throws IOException { */ Map children(OperationPurpose purpose) throws IOException; - @Deprecated(forRemoval = true) - default Map children() throws IOException { - return children(OperationPurpose.SNAPSHOT); - } - /** * Lists all blobs in the container that match the specified prefix. * @@ -262,11 +202,6 @@ default Map children() throws IOException { */ Map listBlobsByPrefix(OperationPurpose purpose, String blobNamePrefix) throws IOException; - @Deprecated(forRemoval = true) - default Map listBlobsByPrefix(String blobNamePrefix) throws IOException { - return listBlobsByPrefix(OperationPurpose.SNAPSHOT, blobNamePrefix); - } - /** * Atomically sets the value stored at the given key to {@code updated} if the {@code current value == expected}. * Keys not yet used start at initial value 0. Returns the current value (before it was updated). @@ -286,16 +221,6 @@ void compareAndExchangeRegister( ActionListener listener ); - @Deprecated(forRemoval = true) - default void compareAndExchangeRegister( - String key, - BytesReference expected, - BytesReference updated, - ActionListener listener - ) { - compareAndExchangeRegister(OperationPurpose.SNAPSHOT, key, expected, updated, listener); - } - /** * Atomically sets the value stored at the given key to {@code updated} if the {@code current value == expected}. * Keys not yet used start at initial value 0. @@ -323,11 +248,6 @@ default void compareAndSetRegister( ); } - @Deprecated(forRemoval = true) - default void compareAndSetRegister(String key, BytesReference expected, BytesReference updated, ActionListener listener) { - compareAndSetRegister(OperationPurpose.SNAPSHOT, key, expected, updated, listener); - } - /** * Gets the value set by {@link #compareAndSetRegister} or {@link #compareAndExchangeRegister} for a given key. * If a key has not yet been used, the initial value is an empty {@link BytesReference}. @@ -341,9 +261,4 @@ default void getRegister(OperationPurpose purpose, String key, ActionListener listener) { - getRegister(OperationPurpose.SNAPSHOT, key, listener); - } - } diff --git a/server/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java b/server/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java index 4b602822f5f2f..8fd04906b1803 100644 --- a/server/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java +++ b/server/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java @@ -23,26 +23,13 @@ public interface BlobStore extends Closeable { */ BlobContainer blobContainer(BlobPath path); - /** - * Delete all the provided blobs from the blob store. Each blob could belong to a different {@code BlobContainer} - * @param blobNames the blobs to be deleted - */ - @Deprecated(forRemoval = true) - default void deleteBlobsIgnoringIfNotExists(Iterator blobNames) throws IOException { - deleteBlobsIgnoringIfNotExists(OperationPurpose.SNAPSHOT, blobNames); - } - - // TODO: Remove the default implementation and require each blob store to implement this method. Once it's done, remove the - // the above overload version that does not take the Purpose parameter. /** * Delete all the provided blobs from the blob store. Each blob could belong to a different {@code BlobContainer} * * @param purpose the purpose of the delete operation * @param blobNames the blobs to be deleted */ - default void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator blobNames) throws IOException { - throw new UnsupportedOperationException(); - } + void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator blobNames) throws IOException; /** * Returns statistics on the count of operations that have been performed on this blob store 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 97b0448107330..33e682354c9cc 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -2959,6 +2959,7 @@ private void doSnapshotShard(SnapshotShardContext context) { }, e -> { try { shardContainer.deleteBlobsIgnoringIfNotExists( + OperationPurpose.SNAPSHOT, Iterators.flatMap(fileToCleanUp.get().iterator(), f -> Iterators.forRange(0, f.numberOfParts(), f::partName)) ); } catch (Exception innerException) {