Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RawClients from Blobs #4375

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.storage.blob.implementation.AzureBlobStorageBuilder;
import com.azure.storage.blob.models.AppendBlobAccessConditions;
import com.azure.storage.blob.models.AppendBlobItem;
Expand All @@ -13,12 +14,13 @@
import com.azure.storage.blob.models.BlobRange;
import com.azure.storage.blob.models.Metadata;
import com.azure.storage.blob.models.SourceModifiedAccessConditions;
import io.netty.buffer.Unpooled;
import io.netty.buffer.ByteBuf;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.net.URL;
import java.nio.ByteBuffer;

import static com.azure.storage.blob.Utility.postProcessResponse;


/**
Expand All @@ -45,8 +47,6 @@
* object through {@link Mono#toFuture()}.
*/
public final class AppendBlobAsyncClient extends BlobAsyncClient {
final AppendBlobAsyncRawClient appendBlobAsyncRawClient;

/**
* Indicates the maximum number of bytes that can be sent in a call to appendBlock.
*/
Expand All @@ -63,7 +63,6 @@ public final class AppendBlobAsyncClient extends BlobAsyncClient {
*/
AppendBlobAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder, String snapshot) {
super(azureBlobStorageBuilder, snapshot);
appendBlobAsyncRawClient = new AppendBlobAsyncRawClient(azureBlobStorageBuilder.build());
}

/**
Expand All @@ -90,8 +89,13 @@ public Mono<Response<AppendBlobItem>> create() {
* A reactive response containing the information of the created appended blob.
*/
public Mono<Response<AppendBlobItem>> create(BlobHTTPHeaders headers, Metadata metadata, BlobAccessConditions accessConditions) {
return appendBlobAsyncRawClient
.create(headers, metadata, accessConditions)
metadata = (metadata == null) ? new Metadata() : metadata;
accessConditions = (accessConditions == null) ? new BlobAccessConditions() : accessConditions;

return postProcessResponse(this.azureBlobStorage.appendBlobs().createWithRestResponseAsync(null,
null, 0, null, metadata, null, null,
null, null, headers, accessConditions.leaseAccessConditions(),
accessConditions.modifiedAccessConditions(), Context.NONE))
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
}

Expand All @@ -111,7 +115,7 @@ public Mono<Response<AppendBlobItem>> create(BlobHTTPHeaders headers, Metadata m
* @return
* A reactive response containing the information of the append blob operation.
*/
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuffer> data, long length) {
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuf> data, long length) {
return this.appendBlock(data, length, null);
}

Expand All @@ -133,10 +137,17 @@ public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuffer> data, long le
* @return
* A reactive response containing the information of the append blob operation.
*/
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuffer> data, long length,
AppendBlobAccessConditions appendBlobAccessConditions) {
return appendBlobAsyncRawClient
.appendBlock(data.map(Unpooled::wrappedBuffer), length, appendBlobAccessConditions)
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuf> data, long length,
AppendBlobAccessConditions appendBlobAccessConditions) {
appendBlobAccessConditions = appendBlobAccessConditions == null ? new AppendBlobAccessConditions()
: appendBlobAccessConditions;

return postProcessResponse(this.azureBlobStorage.appendBlobs().appendBlockWithRestResponseAsync(
null, null, data, length, null, null,
null, null, null, null,
appendBlobAccessConditions.leaseAccessConditions(),
appendBlobAccessConditions.appendPositionAccessConditions(),
appendBlobAccessConditions.modifiedAccessConditions(), Context.NONE))
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
}

Expand Down Expand Up @@ -183,8 +194,16 @@ public Mono<Response<AppendBlobItem>> appendBlockFromUrl(URL sourceURL, BlobRang
public Mono<Response<AppendBlobItem>> appendBlockFromUrl(URL sourceURL, BlobRange sourceRange,
byte[] sourceContentMD5, AppendBlobAccessConditions destAccessConditions,
SourceModifiedAccessConditions sourceAccessConditions) {
return appendBlobAsyncRawClient
.appendBlockFromUrl(sourceURL, sourceRange, sourceContentMD5, destAccessConditions, sourceAccessConditions)
sourceRange = sourceRange == null ? new BlobRange(0) : sourceRange;
destAccessConditions = destAccessConditions == null
? new AppendBlobAccessConditions() : destAccessConditions;

return postProcessResponse(
this.azureBlobStorage.appendBlobs().appendBlockFromUrlWithRestResponseAsync(null, null,
sourceURL, 0, sourceRange.toString(), sourceContentMD5, null, null,
destAccessConditions.leaseAccessConditions(),
destAccessConditions.appendPositionAccessConditions(),
destAccessConditions.modifiedAccessConditions(), sourceAccessConditions, Context.NONE))
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
}
}

This file was deleted.

Loading