-
Notifications
You must be signed in to change notification settings - Fork 853
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
Implementing BatchManager in sdk-core #2613
Implementing BatchManager in sdk-core #2613
Conversation
…-explanatory. Also refactored sdk-core tests
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
.../src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchAndSendFunction.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Outdated
Show resolved
Hide resolved
services/sqs/src/test/java/software/amazon/awssdk/services/sqs/BatchBufferSqsTest.java
Outdated
Show resolved
Hide resolved
…-response correlation checking
… need for requestBufferCopy
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
batchKey
is better thanbatchGroupId
, WDYT? - Looks like
GetBatchGroupIdFunction
is missing from the PR. Let's fix it. Also, how about naming itBatchKeyMapper
?
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchingGroupMap.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchingGroupMap.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchingGroupMap.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchingGroupMap.java
Outdated
Show resolved
Hide resolved
…uration to manage configuration values
…sh was a manual flush. Also adding batchUtils
…nd remove request methods
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.
Overall LGTM. Good job! Just left a few very minor comments.
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/core/internal/batchutilities/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchutilities/BatchManager.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/software/amazon/awssdk/core/internal/batchutilities/BatchBufferTest.java
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/core/internal/batchutilities/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/core/internal/batchutilities/BatchOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. |
Code smells reported by sonarcloud are mostly not related to the change. The code smells that do relate to the changes made in this PR have to do with how I name some generics but those follow the style of the V2 SDK (ex. RequestT as opposed to just T). |
…1a6a0606f Pull request: release <- staging/0d1d0d73-fb64-4c0d-82bd-9b21a6a0606f
private volatile boolean isCancelled = false; | ||
private volatile boolean hasExecuted = false; |
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.
You don't need to make these variables volatile if you only access them using synchronized
blocks.
See Java - is volatile required with synchronized? on StackOverflow and volatile
fields in the Java Language Specification.
Motivation and Context
The general batching solution in sdk-core will eventually allow for feature parity with v1 SQS buffered client as requested here. This will also streamline batch write operations for services that already support batch requests (ex. SQS with sendMessageBatch, Kinesis with putRecords).
Description
Implemented the core batch manager with generic functionality to automatically batch requests client-side. This PR mainly implements the sendRequest method that automatically buffers outgoing requests and flushes them when (a) a maxBatchItems limit is reached or (b) a timeout occurs as specified by the maxBatchOpenInMs parameter.
Testing
Changes were tested with two sets of junit tests. The first is a set of generic tests that are implemented in sdk-core. It passes arbitrary functions to the batch manager and is used to test the general functionality of the batch manager. This includes tests to see whether requests are flushed when reaching the maxBatchItems limit, whether timeouts work, and whether or not multi-threading would break the batch manager. A second set of tests are implemented in SQS to show how the batch manager might interact with an AWS service. These tests are essentially the same as the generic tests but the functions provided are SQS specific (ie they actually send the requests to SQS).
Types of changes
Checklist
mvn install
succeedsLicense