Skip to content

Commit

Permalink
Remove deprecated methods from BlobStore and BlobContainer (elastic#1…
Browse files Browse the repository at this point in the history
…00177)

All their usages have been replaced by corresponding new versions.

Relates: elastic#99615
  • Loading branch information
ywangd authored Oct 3, 2023
1 parent 8d50534 commit 1c86da0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
Expand All @@ -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)}.
*
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
Expand All @@ -164,16 +139,6 @@ void writeMetadataBlob(
CheckedConsumer<OutputStream, IOException> writer
) throws IOException;

@Deprecated(forRemoval = true)
default void writeMetadataBlob(
String blobName,
boolean failIfAlreadyExists,
boolean atomic,
CheckedConsumer<OutputStream, IOException> 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.
Expand All @@ -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.
*
Expand All @@ -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.
Expand All @@ -216,11 +171,6 @@ default DeleteResult delete() throws IOException {
*/
void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException;

@Deprecated(forRemoval = true)
default void deleteBlobsIgnoringIfNotExists(Iterator<String> blobNames) throws IOException {
deleteBlobsIgnoringIfNotExists(OperationPurpose.SNAPSHOT, blobNames);
}

/**
* Lists all blobs in the container.
*
Expand All @@ -230,11 +180,6 @@ default void deleteBlobsIgnoringIfNotExists(Iterator<String> blobNames) throws I
*/
Map<String, BlobMetadata> listBlobs(OperationPurpose purpose) throws IOException;

@Deprecated(forRemoval = true)
default Map<String, BlobMetadata> 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
Expand All @@ -246,11 +191,6 @@ default Map<String, BlobMetadata> listBlobs() throws IOException {
*/
Map<String, BlobContainer> children(OperationPurpose purpose) throws IOException;

@Deprecated(forRemoval = true)
default Map<String, BlobContainer> children() throws IOException {
return children(OperationPurpose.SNAPSHOT);
}

/**
* Lists all blobs in the container that match the specified prefix.
*
Expand All @@ -262,11 +202,6 @@ default Map<String, BlobContainer> children() throws IOException {
*/
Map<String, BlobMetadata> listBlobsByPrefix(OperationPurpose purpose, String blobNamePrefix) throws IOException;

@Deprecated(forRemoval = true)
default Map<String, BlobMetadata> 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).
Expand All @@ -286,16 +221,6 @@ void compareAndExchangeRegister(
ActionListener<OptionalBytesReference> listener
);

@Deprecated(forRemoval = true)
default void compareAndExchangeRegister(
String key,
BytesReference expected,
BytesReference updated,
ActionListener<OptionalBytesReference> 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.
Expand Down Expand Up @@ -323,11 +248,6 @@ default void compareAndSetRegister(
);
}

@Deprecated(forRemoval = true)
default void compareAndSetRegister(String key, BytesReference expected, BytesReference updated, ActionListener<Boolean> 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}.
Expand All @@ -341,9 +261,4 @@ default void getRegister(OperationPurpose purpose, String key, ActionListener<Op
compareAndExchangeRegister(purpose, key, BytesArray.EMPTY, BytesArray.EMPTY, listener);
}

@Deprecated(forRemoval = true)
default void getRegister(String key, ActionListener<OptionalBytesReference> listener) {
getRegister(OperationPurpose.SNAPSHOT, key, listener);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> blobNames) throws IOException {
throw new UnsupportedOperationException();
}
void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException;

/**
* Returns statistics on the count of operations that have been performed on this blob store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1c86da0

Please sign in to comment.