Skip to content

Adding batchManager() method into code generated sync and async clients #2666

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

Conversation

16lim21
Copy link
Contributor

@16lim21 16lim21 commented Aug 18, 2021

Motivation and Context

Users should have the option to be able to create a batchManager() directly from a low level sqs client as outlined in the design document. Changes also had to be made to the generated clients to ensure that they contained the necessary executor/scheduledExecutor that would be used by the batchManager.

Description

Added some changes to how the sync and async clients (as well as their corresponding interfaces) are generated. Specifically added in the batchManager() method to create a batchManager for that service. Executors and ScheduledExecutors were also added to the underlying clients if they supported the batchManager() method.

Testing

Added some codegen tests to check the generated classes and interfaces matched expectations. Also modified existing SqsBatchManager tests to use the client's batchManager instead of creating one separately.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

Michael Li added 21 commits August 17, 2021 11:13
Allows for either an exception or response to be returned by the responseMapper. Also adding tests and option to specify batchKey and batchBuffer limits.
…manager return type to customization config
…s' into feature/master/automatic-request-batching

# Conflicts:
#	core/sdk-core/src/main/java/software/amazon/awssdk/core/batchmanager/BatchOverrideConfiguration.java
#	core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchBuffer.java
#	core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchConfiguration.java
#	core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchingMap.java
#	core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/DefaultBatchManager.java
#	core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/batchmanager/BatchManagerTest.java
Copy link
Contributor

@zoewangg zoewangg left a comment

Choose a reason for hiding this comment

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

Don't we need to modify the customization config in sqs?

@16lim21
Copy link
Contributor Author

16lim21 commented Aug 19, 2021

Sonarcloud fails due to 4 lines of duplicated code across the SyncClientInterface and AsyncClientInterface. The duplicated code just gets the batchManagerMethod which and adds it.

@@ -134,7 +134,7 @@ static Builder builder() {
* @param executor the executor to be used.
* @returna reference to this object so that method calls can be chained together.
*/
Builder executor(Executor executor);
Builder executor(ExecutorService executor);
Copy link
Contributor

@zoewangg zoewangg Aug 19, 2021

Choose a reason for hiding this comment

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

Hmm, why did we revert it back to Executor ExecutorService? If lack of shutdown is the reason, we can cast the created executor to executor service and call shutdown. https://github.com/aws/aws-sdk-java-v2/blob/master/utils/src/main/java/software/amazon/awssdk/utils/AttributeMap.java#L91-L93

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 originally changed it to Executor when I was trying to access the client's FUTURE_COMPLETION_EXECUTOR. Since they sync client doesn't have that executor, it was ok to revert back to an ExecutorService.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

96.1% 96.1% Coverage
3.0% 3.0% Duplication

@zoewangg zoewangg merged commit 179ac87 into aws:feature/master/automatic-request-batching Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants