Skip to content

Commit 570632c

Browse files
authored
Feature Work for Storage (#4584)
* Storage SAS implementation (#4404) * SAS implementation * Fixed some minor formatting issues * Fixed checkstyle problems and test issue * Remove RawClients from Blobs (#4375) Removes RawClients from Storage Blobs * Add deleteContainer to StorageClient and getBlobClient with Snapshot to ContainerClient (#4376) * Removed raw clients * Added deleteContainer to StorageClient * Added getAppendBlob with snapshot to ContainerClient * Storage queue linting, builder refactor, tests (#4383) * Initial check in for storage queue * Initial checkin for Storage file (#4414) * Finished the restructure, refactor builder. Added sleep in record feature. Linting * Merge Storage Blob Client Builders (#4468) Merges AppendBlobClientBuilder, BlobClientBuilder, BlockBlobClientBuilder, and PageBlobClientBuilder into a single builder class BlobClientBuilder. Additionally, JavaDoc comments for the other builder classes, ContainerClientBuilder and StorageAccountClientBuilder, were cleaned up and the way the endpoint is handled in builders was changed.
1 parent c0d1663 commit 570632c

File tree

314 files changed

+33989
-7180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+33989
-7180
lines changed

eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
<Match>
369369
<Or>
370370
<Package name="com.microsoft.azure.storage.blob"/>
371+
<Package name="com.azure.storage.file.models"/>
371372
<Class name="com.azure.storage.blob.HTTPGetterInfo"/>
372373
</Or>
373374
<Bug pattern="NM_CONFUSING"/>
@@ -439,6 +440,7 @@
439440
<Or>
440441
<Class name="com.azure.storage.blob.BlobInputStream"/>
441442
<Class name="com.azure.storage.blob.BlobOutputStream"/>
443+
<Class name="com.azure.storage.queue.QueueServiceClient"/>
442444
</Or>
443445
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
444446
</Match>

eng/jacoco-test-coverage/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<azure-keyvault.version>4.0.0-preview.1</azure-keyvault.version>
3333
<azure-messaging-eventhubs.version>5.0.0-preview.2</azure-messaging-eventhubs.version>
3434
<azure-storage-blob.version>12.0.0-preview.1</azure-storage-blob.version>
35+
<azure-storage-queue.version>12.0.0-preview.1</azure-storage-queue.version>
3536
</properties>
3637

3738
<distributionManagement>
@@ -93,7 +94,11 @@
9394
<!-- <artifactId>azure-storage-blob</artifactId>-->
9495
<!-- <version>${azure-storage-blob.version}</version>-->
9596
<!-- </dependency>-->
96-
97+
<dependency>
98+
<groupId>com.azure</groupId>
99+
<artifactId>azure-storage-queue</artifactId>
100+
<version>${azure-storage-queue.version}</version>
101+
</dependency>
97102
<!-- Tracing will be built and released separately. Removing tracing dependency
98103
until we finalize dependency composition -->
99104
<!-- <dependency>-->

eng/spotbugs-aggregate-report/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
<azure-keyvault.version>4.0.0-preview.1</azure-keyvault.version>
3131
<azure-messaging-eventhubs.version>5.0.0-preview.2</azure-messaging-eventhubs.version>
3232
<azure-storage.version>12.0.0-preview.1</azure-storage.version>
33+
<azure-storage-file.version>12.0.0-preview.1</azure-storage-file.version>
34+
<azure-storage-queue.version>12.0.0-preview.1</azure-storage-queue.version>
3335
</properties>
3436
<distributionManagement>
3537
<site>
@@ -183,6 +185,16 @@
183185
<!-- <version>${azure-storage.version}</version>-->
184186
<!-- </dependency>-->
185187

188+
<dependency>
189+
<groupId>com.azure</groupId>
190+
<artifactId>azure-storage-file</artifactId>
191+
<version>${azure-storage-file.version}</version>
192+
</dependency>
193+
<dependency>
194+
<groupId>com.azure</groupId>
195+
<artifactId>azure-storage-queue</artifactId>
196+
<version>${azure-storage-queue.version}</version>
197+
</dependency>
186198
<!-- Added this dependency to include necessary annotations used by reactor core.
187199
Without this dependency, javadoc throws a warning as it cannot find enum When.MAYBE
188200
which is used in @Nullable annotation in reactor core classes -->

pom.client.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,14 @@
393393
<title>Azure Storage - Blobs</title>
394394
<packages>com.azure.storage.blob*</packages>
395395
</group>
396+
<group>
397+
<title>Azure Storage - Files</title>
398+
<packages>com.azure.storage.file*</packages>
399+
</group>
400+
<group>
401+
<title>Azure Storage - Queues</title>
402+
<packages>com.azure.storage.queue*</packages>
403+
</group>
396404
</groups>
397405
<links>
398406
<link>https://docs.oracle.com/javase/8/docs/api/</link>
@@ -537,7 +545,8 @@
537545
-snippetpath ${project.basedir}/sdk/eventhubs/azure-eventhubs/src/samples/java
538546
-snippetpath ${project.basedir}/sdk/keyvault/azure-keyvault-keys/src/samples/java
539547
-snippetpath ${project.basedir}/sdk/keyvault/azure-keyvault-secrets/src/samples/java
540-
<!-- -snippetpath ${project.basedir}/storage/client/blob/src/samples/java-->
548+
<!-- -snippetpath ${project.basedir}/storage/client/blob/src/samples/java-->
549+
-snippetpath ${project.basedir}/storage/client/queue/src/samples/java
541550
</additionalOptions>
542551
</configuration>
543552
</reportSet>
@@ -736,5 +745,7 @@
736745
<!-- <module>./sdk/tracing</module>-->
737746
<module>./sdk/identity/azure-identity</module>
738747
<module>./storage/client/blob</module>
748+
<module>./storage/client/file</module>
749+
<module>./storage/client/queue</module>
739750
</modules>
740751
</project>

sdk/keyvault/azure-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/KeyVaultErrorCodeStrings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ private static synchronized void loadProperties() {
4545
}
4646

4747

48-

storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.azure.core.http.rest.Response;
77
import com.azure.core.http.rest.SimpleResponse;
8+
import com.azure.core.util.Context;
89
import com.azure.storage.blob.implementation.AzureBlobStorageBuilder;
910
import com.azure.storage.blob.models.AppendBlobAccessConditions;
1011
import com.azure.storage.blob.models.AppendBlobItem;
@@ -13,17 +14,18 @@
1314
import com.azure.storage.blob.models.BlobRange;
1415
import com.azure.storage.blob.models.Metadata;
1516
import com.azure.storage.blob.models.SourceModifiedAccessConditions;
16-
import io.netty.buffer.Unpooled;
17+
import io.netty.buffer.ByteBuf;
1718
import reactor.core.publisher.Flux;
1819
import reactor.core.publisher.Mono;
1920

2021
import java.net.URL;
21-
import java.nio.ByteBuffer;
22+
23+
import static com.azure.storage.blob.Utility.postProcessResponse;
2224

2325

2426
/**
25-
* Client to an append blob. It may only be instantiated through a {@link AppendBlobClientBuilder#buildAsyncClient()}, via
26-
* the method {@link BlobAsyncClient#asAppendBlobAsyncClient()}, or via the method
27+
* Client to an append blob. It may only be instantiated through a {@link BlobClientBuilder#buildAppendBlobAsyncClient()},
28+
* via the method {@link BlobAsyncClient#asAppendBlobAsyncClient()}, or via the method
2729
* {@link ContainerAsyncClient#getAppendBlobAsyncClient(String)}. This class does not hold
2830
* any state about a particular blob, but is instead a convenient way of sending appropriate
2931
* requests to the resource on the service.
@@ -45,8 +47,6 @@
4547
* object through {@link Mono#toFuture()}.
4648
*/
4749
public final class AppendBlobAsyncClient extends BlobAsyncClient {
48-
final AppendBlobAsyncRawClient appendBlobAsyncRawClient;
49-
5050
/**
5151
* Indicates the maximum number of bytes that can be sent in a call to appendBlock.
5252
*/
@@ -58,12 +58,11 @@ public final class AppendBlobAsyncClient extends BlobAsyncClient {
5858
public static final int MAX_BLOCKS = 50000;
5959

6060
/**
61-
* Package-private constructor for use by {@link AppendBlobClientBuilder}.
61+
* Package-private constructor for use by {@link BlobClientBuilder}.
6262
* @param azureBlobStorageBuilder the API client builder for blob storage API
6363
*/
6464
AppendBlobAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder, String snapshot) {
6565
super(azureBlobStorageBuilder, snapshot);
66-
appendBlobAsyncRawClient = new AppendBlobAsyncRawClient(azureBlobStorageBuilder.build());
6766
}
6867

6968
/**
@@ -90,8 +89,13 @@ public Mono<Response<AppendBlobItem>> create() {
9089
* A reactive response containing the information of the created appended blob.
9190
*/
9291
public Mono<Response<AppendBlobItem>> create(BlobHTTPHeaders headers, Metadata metadata, BlobAccessConditions accessConditions) {
93-
return appendBlobAsyncRawClient
94-
.create(headers, metadata, accessConditions)
92+
metadata = (metadata == null) ? new Metadata() : metadata;
93+
accessConditions = (accessConditions == null) ? new BlobAccessConditions() : accessConditions;
94+
95+
return postProcessResponse(this.azureBlobStorage.appendBlobs().createWithRestResponseAsync(null,
96+
null, 0, null, metadata, null, null,
97+
null, null, headers, accessConditions.leaseAccessConditions(),
98+
accessConditions.modifiedAccessConditions(), Context.NONE))
9599
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
96100
}
97101

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

@@ -133,10 +137,17 @@ public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuffer> data, long le
133137
* @return
134138
* A reactive response containing the information of the append blob operation.
135139
*/
136-
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuffer> data, long length,
137-
AppendBlobAccessConditions appendBlobAccessConditions) {
138-
return appendBlobAsyncRawClient
139-
.appendBlock(data.map(Unpooled::wrappedBuffer), length, appendBlobAccessConditions)
140+
public Mono<Response<AppendBlobItem>> appendBlock(Flux<ByteBuf> data, long length,
141+
AppendBlobAccessConditions appendBlobAccessConditions) {
142+
appendBlobAccessConditions = appendBlobAccessConditions == null ? new AppendBlobAccessConditions()
143+
: appendBlobAccessConditions;
144+
145+
return postProcessResponse(this.azureBlobStorage.appendBlobs().appendBlockWithRestResponseAsync(
146+
null, null, data, length, null, null,
147+
null, null, null, null,
148+
appendBlobAccessConditions.leaseAccessConditions(),
149+
appendBlobAccessConditions.appendPositionAccessConditions(),
150+
appendBlobAccessConditions.modifiedAccessConditions(), Context.NONE))
140151
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
141152
}
142153

@@ -183,8 +194,16 @@ public Mono<Response<AppendBlobItem>> appendBlockFromUrl(URL sourceURL, BlobRang
183194
public Mono<Response<AppendBlobItem>> appendBlockFromUrl(URL sourceURL, BlobRange sourceRange,
184195
byte[] sourceContentMD5, AppendBlobAccessConditions destAccessConditions,
185196
SourceModifiedAccessConditions sourceAccessConditions) {
186-
return appendBlobAsyncRawClient
187-
.appendBlockFromUrl(sourceURL, sourceRange, sourceContentMD5, destAccessConditions, sourceAccessConditions)
197+
sourceRange = sourceRange == null ? new BlobRange(0) : sourceRange;
198+
destAccessConditions = destAccessConditions == null
199+
? new AppendBlobAccessConditions() : destAccessConditions;
200+
201+
return postProcessResponse(
202+
this.azureBlobStorage.appendBlobs().appendBlockFromUrlWithRestResponseAsync(null, null,
203+
sourceURL, 0, sourceRange.toString(), sourceContentMD5, null, null,
204+
destAccessConditions.leaseAccessConditions(),
205+
destAccessConditions.appendPositionAccessConditions(),
206+
destAccessConditions.modifiedAccessConditions(), sourceAccessConditions, Context.NONE))
188207
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
189208
}
190209
}

0 commit comments

Comments
 (0)