-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Storage queue linting, builder refactor, tests #4383
Storage queue linting, builder refactor, tests #4383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the jacoco pom file needs to be updated to include Storage Queues
storage/client/queue/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueClient.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/main/java/com/azure/storage/queue/models/DequeuedMessage.java
Show resolved
Hide resolved
storage/client/queue/src/samples/java/com/azure/storage/queue/AsyncSamples.java
Outdated
Show resolved
Hide resolved
storage/client/queue/src/samples/java/com/azure/storage/queue/MessageSample.java
Outdated
Show resolved
Hide resolved
@alzimmermsft Added storage queue as a dependency |
|
storage/client/queue/README.md
Outdated
@@ -221,7 +220,7 @@ queueServiceClient.listQueuesSegment(marker, options).forEach{ | |||
Get queue properties in account, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. | |||
```Java | |||
String queueServiceURL = String.format("https://%s.queue.core.windows.net/%s", accountName, sasToken) | |||
QueueServiceClient queueServiceClient = QueueServiceClient.builder().endpoint(queueURL).build(); | |||
QueueServiceClient queueServiceClient = new QueueServiceClientBuilder().endpoint(queueURL).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching up:
Didn't we want people to use the static method on the client to get the builder? Are we removing those now, or do we just want to make the sample look less cluttered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final design of how people instantiate clients is now as shown above - there are no longer .builder()
methods on the individual client classes, instead users are directed to using the builder class directly. It saves in confusion where a user may do something like QueueServiceClient.builder().endpoint(...).buildAsyncClient()
and wonder slightly why they started with a sync client class but ended up with an async client. CheckStyle rules are in development to ensure consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JonathanGiles
private URL endpoint; | ||
private String queueName; | ||
private SASTokenCredential sasTokenCredential; | ||
private SharedKeyCredential sharedKeyCredential; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a TokenCredential option, like the blob service has.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the tokenCredential used for in queue?
To create a Storage Account you can use the Azure Portal or [Azure CLI][azure_cli]. | ||
|
||
```Powershell | ||
az group create \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the backslashes for? Maybe just a syntax mistake? Because this differs from your other multiline powershell snippits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used for multi-line commands in bash. I checked other client library, they did not have the multi-line format. I will change it to one line command.
### QueueClient | ||
Once you have the value of the SASToken you can create the queue service client with `${accountName}`, `${queueName}`, `${sasToken}`. | ||
```Java | ||
String queueURL = String.format("https://%s.queue.core.windows.net/%s%s", accountName, queueName, sasToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General note:
We have a builder specifically so people don't have to engineer their URLs, and then all our samples are us engineering URLs. I think it's important to show that if you already have a full URL, you can just use it. But we should be showing how to use our builders in these samples instead of doing string manipulation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what we have several weeks ago. Will illustrate how to build clients in another example. And use the builder one for all the rest code examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An early pass on a few of the files in this PR. It would be wise to get this codebase updated to the latest Azure Core version. What is the plan there?
eng/jacoco-test-coverage/pom.xml
Outdated
@@ -31,6 +31,7 @@ | |||
<azure-identity.version>1.0.0-preview.1</azure-identity.version> | |||
<azure-keyvault.version>4.0.0-preview.1</azure-keyvault.version> | |||
<azure-messaging-eventhubs.version>5.0.0-preview.2</azure-messaging-eventhubs.version> | |||
<azure-storage-queue.version>12.0.0-preview.1</azure-storage-queue.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these should go in alphabetical order, so 'queue' comes after 'blob'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
eng/jacoco-test-coverage/pom.xml
Outdated
<groupId>com.azure</groupId> | ||
<artifactId>azure-storage-queue</artifactId> | ||
<version>${azure-storage-queue.version}</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetical here (based on artifactId) - push to after blob below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<groupId>com.azure</groupId> | ||
<artifactId>azure-storage-queue</artifactId> | ||
<version>${azure-storage-queue.version}</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* <ul> | ||
* <li> There is only one null value for retryDelay and maxRetryDelay.<li/> | ||
* <li> Unrecognized retry policy type.<li/> | ||
* </ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better - but the indentation is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I aligned with the start point of the description. Follow the format above. Could you explain it more where these line should be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it all the way to the left with just a space (or a few of them at most).
storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
Outdated
Show resolved
Hide resolved
private final String queueName; | ||
|
||
/** | ||
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl#url() endpoint}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a public method, so it is not visible to users. However, please validate all JavaDoc for issues. For example, here AzureQueueStorageImpl is not public API, so it should not be referred to in JavaDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove the link here. And review for the rest.
try { | ||
return new URL(client.url()); | ||
} catch (MalformedURLException ex) { | ||
throw new RuntimeException("Queue URL is malformed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClientLogger.logAndThrow all exceptions. Please search for all cases because soon Shawn will check in his CheckStyle rule and it will break the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean I added a log message before throw statement. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Just call Logger.logAndThrow(new RuntimeException("....")
and then return null
afterwards.
|
||
/** | ||
* @return the URL of the storage queue | ||
* @throws RuntimeException If the queue is using a malformed URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a way for this to be malformed? If it was we would have identified it in the builder before this class was ever created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it has a chance of being thrown, but It is a checked exception. It needs to be handled either in try/catch or in signature. Alan and I both think it is better to do try/catch block.
What is your suggestion about handling the exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to swallow the exception
Queue, file will have the same schedule with Blob to move to core preview 3. @alzimmermsft suggested to put it to storage preview 3. @alzimmermsft please correct me if you have anything else on top of your plan. |
James and Jonathan agreed to merge in the PR and addressed all issues in Epic for next round. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing items have been agreed to be addressed in a later PR.
String queueServiceURL = String.format("https://%s.queue.core.windows.net/%s", accountName, sasToken) | ||
QueueServiceClient queueServiceClient = QueueServiceClient.builder().endpoint(queueURL).build(); | ||
String queueServiceURL = String.format("https://%s.queue.core.windows.net", accountName) | ||
QueueServiceClient queueServiceClient = new QueueServiceClientBuilder().endpoint(queueURL).credential(SASToken).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall, the QueueServiceClientBuilder
class is either being renamed or has been renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not realize we need to rename the builder for this PR. There is a proposal to rename the QueueServiceClient -> QueueStorageClient.
I will address the rename in issue #4532
|
||
<groupId>com.azure</groupId> | ||
<artifactId>azure-storage-queue</artifactId> | ||
<version>12.0.0-preview.1</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is queues going to release as preview 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alzimmermsft said we can have the version number 12.0.0-preview.1
I did not aware of any other proposal.
Let me know if we need to change to something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be changed to Preview 2, File, Queues, and the Common package will all skip Preview 1 to be consistent with Blobs and the other languages.
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slf4j shouldn't be required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nor here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>adal4j</artifactId> | ||
<scope>test</scope> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is reactor-test or adal4j used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed adal4j
Reator-test is necessary for async tests.
* @throws InvalidKeyException If the accountKey is not a valid Base64-encoded string. | ||
* @throws RuntimeException for one of the following cases: | ||
* - If the HMAC-SHA256 signature for {@code sharedKeyCredentials} fails to generate. | ||
* - If the an invalid key has been given to the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The javadoc should be fixed before it is merged - it is just a formatting issue, not a logic issue.
} catch (final NoSuchAlgorithmException e) { | ||
throw new RuntimeException(e); | ||
} catch (InvalidKeyException e) { | ||
throw new RuntimeException("Please double check the account key. Error details: " + e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not correct. Use logAndThrow
* <ul> | ||
* <li> There is only one null value for retryDelay and maxRetryDelay.<li/> | ||
* <li> Unrecognized retry policy type.<li/> | ||
* </ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it all the way to the left with just a space (or a few of them at most).
|
||
/** | ||
* @return the URL of the storage queue | ||
* @throws RuntimeException If the queue is using a malformed URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to swallow the exception
try { | ||
return new URL(client.url()); | ||
} catch (MalformedURLException ex) { | ||
throw new RuntimeException("Queue URL is malformed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Just call Logger.logAndThrow(new RuntimeException("....")
and then return null
afterwards.
I gave feedback that has not been addressed, yet this PR was merged. Were issues filed or have these been fixed? I'm not super keen to have PRs merged when people are still discussing it (regardless of it is myself or anyone else). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave feedback that has not been addressed, yet this PR was merged. Were issues filed or have these been fixed? I'm not super keen to have PRs merged when people are still discussing it (regardless of it is myself or anyone else).
I have opened the PR over the weekend. Did not realize you have new comments right here.
I have open another PR to address all the comments here.
Sorry for the confusion.
* 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.
* 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 storage swaggers * Update Storage to azure-core preview 3 * 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 * Address code review feedback in AutoRest * 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. * Regenerate blob file queue after merge * Up azure core version for file & queue * Apply all the manual fixes in swagger * Change directoryName to directoryPath * Use non-fluent pattern for generated clients * Fix build after merging with master * Return void on setters * Revert spotbugs config change
* 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 * Beginning of code snippets for BlobAsyncClient * JavaDoc snippets for BlobAsyncClient and BlobClient * Added links to REST API docs for BlobAsyncClient and BlobClient, fixed JavaDoc issues, fix unit test issues * Removed invalid import
Implements #4037
Implements Storage Queues with unit tests, JavaDocs, samples, README, and linting enabled.