-
Notifications
You must be signed in to change notification settings - Fork 914
Codegenerate BatchManager API under AsyncClient and Initail Interfaces for BatchManager #5321
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
Codegenerate BatchManager API under AsyncClient and Initail Interfaces for BatchManager #5321
Conversation
604534e
to
40b2eb3
Compare
… Batchmanager interfaces and Implementations
40b2eb3
to
e1cda0a
Compare
@@ -155,6 +157,10 @@ protected void addFields(TypeSpec.Builder type) { | |||
type.addField(AwsJsonProtocolFactory.class, "jsonProtocolFactory", PRIVATE, FINAL); | |||
} | |||
|
|||
if (model.getCustomizationConfig().getBatchManagerSupported() || model.hasWaiters()) { |
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.
Can we extract this into one conditional method like shouldAddScheduledExecutor
and refer to it in two places?
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
@@ -92,6 +93,12 @@ public void asyncClientCustomPackageName() { | |||
assertThat(syncClientCustomServiceMetaData, generatesTo("test-custompackage-async.java")); | |||
} | |||
|
|||
@Test | |||
public void asyncClientBatchManager() { | |||
ClassSpec syncClientCustomServiceMetaData = createAsyncClientClass(batchManagerModels()); |
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: syncClientCustomServiceMetaData
@@ -134,6 +134,7 @@ final class DefaultJsonAsyncClient implements JsonAsyncClient { | |||
|
|||
private final SdkClientConfiguration clientConfiguration; | |||
|
|||
|
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: unnecessary extra line
* Sets a custom {@link software.amazon.awssdk.services.sqs.SqsClient} for polling resources. This client must be closed | ||
* by the caller. |
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 should describe what happens if the user does not supply this parameter.
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.
When we call sqsClient.batchManager() the sqsManager will be created from this
client, thus it will be nevew null.
However, since SQSBatchManager is public API user can use builder directly , in this case client cannot be null , added a validation check in the builder
...sqs/src/main/java/software/amazon/awssdk/services/sqs/batchmanager/SqsAsyncBatchManager.java
Show resolved
Hide resolved
} | ||
|
||
/** | ||
* Define the the maximum number of messages that are batched together in a single request. |
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 a maximum number for the maximum number? What is the default?
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.
There is no Max number but there is a Default of 10 https://github.com/aws/aws-sdk-java/blob/5b96018acb3eee64d64b8fb87a289e08f3b14694/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/QueueBufferConfig.java#L29
Updated the TODO to make sure we add these values in upcoming PRs
...va/software/amazon/awssdk/services/sqs/internal/batchmanager/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...va/software/amazon/awssdk/services/sqs/internal/batchmanager/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...va/software/amazon/awssdk/services/sqs/internal/batchmanager/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
* @param maxBatchOpenInMs The new maxBatchOpenInMs value. | ||
* @return This object for method chaining. | ||
*/ | ||
public Builder maxBatchOpenInMs(Duration maxBatchOpenInMs) { |
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 most common term to denote milliseconds is Millis
. Can we change?
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.
Or just remove InMs
since it's a Duration ;) We should probably discuss naming in API surface area review because I'm not sure what maxBatchOpen means...
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.
Taken from https://github.com/aws/aws-sdk-java/blob/5b96018acb3eee64d64b8fb87a289e08f3b14694/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/QueueBufferConfig.java#L37-L44
However , will add a TODO to reveiw the names in API surface review
Can we use the existing |
* @param request The SendMessageRequest to be buffered. | ||
* @return CompletableFuture of the corresponding {@link SendMessageResponse}. | ||
*/ | ||
default CompletableFuture<SendMessageResponse> sendMessage(SendMessageRequest request) { |
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.
Probably out of scope of this PR, but we should probably add consumer builder overload (can be addressed in separate PR)
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.
Good point , will mention it as TODO as class level comment
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.sqs.internal.batchmanager; |
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 should move this out of internal package.
* @param maxBatchOpenInMs The new maxBatchOpenInMs value. | ||
* @return This object for method chaining. | ||
*/ | ||
public Builder maxBatchOpenInMs(Duration maxBatchOpenInMs) { |
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.
Or just remove InMs
since it's a Duration ;) We should probably discuss naming in API surface area review because I'm not sure what maxBatchOpen means...
|
These builder Methods are Static APIs on the Client , where as the BatchManager API are non-static methods which are invoked on the client , where client internally uses "this" to build batch Manager. |
d2a4d45
into
feature/master/sqs-batch-manager
…s for BatchManager (#5321) * Codegenerate BatchManager API under AsyncClient and Add empty initial Batchmanager interfaces and Implementations * Addressed review comments
* Codegenerate BatchManager API under AsyncClient and Initail Interfaces for BatchManager (#5321) * Codegenerate BatchManager API under AsyncClient and Add empty initial Batchmanager interfaces and Implementations * Addressed review comments * Added Internal classes required for BatchManager Implementation * Revert "Added Internal classes required for BatchManager Implementation" This reverts commit 318969b. * Internal classes and RequestBatchManager Impelementation (#5418) * Added Internal classes required for BatchManager Implementation * Added Batch Send Implementation * Handled review comments * Handled review comments * Handled review comments * Made RequestBatchManager class a Abstract class * Checkstyle issues * Removed unused methods * New lines removed * Made public static to private state for sqsBatch functions * Constants added * Sonar cloud issues fixed * commit to check why test on codebuild * Increased Timeouts for get * Added abstract methods * Handled comments to remove Builders * Handled comments to take care when batchmanager closed while pending requests * Handled comments * Checkstyle issue * Added Consumer builders args for existing APIs of BatchManager (#5514) * Receive Batch Manager Implementation (#5488) * Add Recieve Buffer Queue And its related configuration * Update ReceiveBatch manager * Recieve Batch Manager Implementation * Receive Batch Manager Implemetation * Handled review comments * Checkstyle failure * Flsky test case fixed * Flaky test case fixed * Hamdled review comments * Handled comments * Removed ReceiveMessageCompletableFuture * SdkClosable implemented * Added ReceiveMessageBatchManager class for completeness * Checkstyle issues * Null checks * Handled comments from Zoe * Updated the defaults to 50ms same as V1 after surface area review * Revert "Updated the defaults to 50ms same as V1 after surface area review" This reverts commit e7d2295. * Bytes Based batching for SendMessageRequest Batching (#5540) * Initial changes * Initial changes 2 * Byte Based batching for SendMessage API * Byte Based batching for SendMessage API * Handled comments * Checkstyle issue * Add User Agent for Sqs Calls made using Automatic Batching Manager (#5546) * Add User Agent for Sqs Calls made using Automatic Batching Manager as hll/abm * Review comments * Update comments from PR 5488 (#5550) * Update comments of PR 5488 * Update comments from PR 5488 * Handled surface area review comments (#5563) * Initial version * Intermediate changes * Update after internal poll * ResponseCOnfiguration construction updated * RequestOverride configuration check added to Bypass batch manager * Handled review comments * Removed TODO since validations are handled in BatchPverrideConfiguration * Fix issue where the Scheduled Timeout was incorrectly completing the futures with empty messages (#5571) * Fix issue where the Scheduled Timeout was incorrectly completing the futures with empty messages * Handled review comments * Integ test for Automatic Request Batching (#5576) * feat(sqs): add BatchManager for client-side request batching to Amazon SQS The new BatchManager allows for simple request batching using client-side buffering, improving cost efficiency and reducing the number of requests sent to Amazon SQS. The client-side buffering supports up to 10 requests per batch and is supported by the SqsAsyncClient. Batched requests, along with receive message polling, help to increase throughput. * Add check for scheduledExecutor such that it not null when creating SqsAsyncBatchManager (#5582) * Add check for scheduledExecutor such that it not null when creating SqsAsyncBatchManager * Update services/sqs/src/test/java/software/amazon/awssdk/services/sqs/batchmanager/SqsAsyncBatchManagerBuilderTest.java Co-authored-by: David Ho <[email protected]> * Update services/sqs/src/test/java/software/amazon/awssdk/services/sqs/batchmanager/SqsAsyncBatchManagerBuilderTest.java Co-authored-by: David Ho <[email protected]> * Update services/sqs/src/test/java/software/amazon/awssdk/services/sqs/batchmanager/SqsAsyncBatchManagerBuilderTest.java Co-authored-by: David Ho <[email protected]> --------- Co-authored-by: David Ho <[email protected]> * Updating Timeouts in gets so that we dont wait infinitely --------- Co-authored-by: David Ho <[email protected]>
Motivation and Context
PR similar to #2666. But following are considered after design reviews
Modifications
Customization
Will result in code
Testing
License