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

Storage queue linting, builder refactor, tests #4383

Merged
merged 17 commits into from
Jul 22, 2019

Conversation

sima-zhu
Copy link
Contributor

@sima-zhu sima-zhu commented Jul 10, 2019

Implements #4037

Implements Storage Queues with unit tests, JavaDocs, samples, README, and linting enabled.

@sima-zhu sima-zhu requested a review from alzimmermsft July 10, 2019 23:37
@praries880 praries880 closed this Jul 11, 2019
@praries880 praries880 reopened this Jul 11, 2019
Copy link
Member

@alzimmermsft alzimmermsft left a 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

@sima-zhu
Copy link
Contributor Author

I think the jacoco pom file needs to be updated to include Storage Queues

@alzimmermsft Added storage queue as a dependency

@sima-zhu sima-zhu requested a review from alzimmermsft July 11, 2019 18:54
@sima-zhu
Copy link
Contributor Author

  • setAccessPolicy changing to varargs and Iterable overload

  • In JavaDocs explain the parameters in order of the argument list

  • DequeueMessages and PeekMessages should have their empty parameter overloads removed

  • Potentially changing the return type of getAccessPolicy to Response<List>

  • StorageException wrapper in postProcessResponse

@@ -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();
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private URL endpoint;
private String queueName;
private SASTokenCredential sasTokenCredential;
private SharedKeyCredential sharedKeyCredential;
Copy link
Member

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.

Copy link
Contributor Author

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 \
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Contributor Author

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.

@alzimmermsft alzimmermsft added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) labels Jul 17, 2019
Copy link
Member

@JonathanGiles JonathanGiles left a 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?

@@ -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>
Copy link
Member

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'.

Copy link
Contributor Author

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>
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

eng/spotbugs-aggregate-report/pom.xml Show resolved Hide resolved
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
<version>${azure-storage-queue.version}</version>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pom.client.xml Show resolved Hide resolved
* <ul>
* <li> There is only one null value for retryDelay and maxRetryDelay.<li/>
* <li> Unrecognized retry policy type.<li/>
* </ul>
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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).

private final String queueName;

/**
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl#url() endpoint}.
Copy link
Member

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.

Copy link
Contributor Author

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");
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

@sima-zhu
Copy link
Contributor Author

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?

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.

@sima-zhu
Copy link
Contributor Author

James and Jonathan agreed to merge in the PR and addressed all issues in Epic for next round.

Copy link
Member

@jaschrep-msft jaschrep-msft left a 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();
Copy link
Member

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?

Copy link
Contributor Author

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>
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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>
Copy link
Member

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.

Copy link
Contributor Author

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nor here

Copy link
Contributor Author

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>
Copy link
Member

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?

Copy link
Contributor Author

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.
Copy link
Member

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());
Copy link
Member

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>
Copy link
Member

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.
Copy link
Member

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");
Copy link
Member

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.

@sima-zhu sima-zhu merged commit 78ea66b into Azure:storage-post-review1-dev Jul 22, 2019
@JonathanGiles
Copy link
Member

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).

Copy link
Contributor Author

@sima-zhu sima-zhu left a 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.

alzimmermsft added a commit that referenced this pull request Jul 25, 2019
* 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.
jianghaolu added a commit that referenced this pull request Jul 29, 2019
* 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
alzimmermsft added a commit that referenced this pull request Jul 30, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants