-
Notifications
You must be signed in to change notification settings - Fork 910
Expose numRetries to configure maxRetries on error in the S3CrtClient Interface #3885
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
442a13c
Expose StandardRetryOptions in the S3CrtClient Interface
joviegas 708a2cb
Merge branch 'master' into joviegas/crt-retry
joviegas 602fd9a
Added wrapper class for CRT retry config
joviegas a688479
Added Null checks and test cases
joviegas 3f11f64
Handled PR comment on javadoc
joviegas b6c1ed2
Handled NIT comments
joviegas e3af202
Resolve merge conflicts
joviegas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "feature", | ||
"category": "AWS SDK for Java v2", | ||
"contributor": "", | ||
"description": "Expose StandardRetryOptions of S3ClientOptions in the S3CrtClient Interface" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
...ices/s3/src/main/java/software/amazon/awssdk/services/s3/crt/S3CrtRetryConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.s3.crt; | ||
|
||
import java.util.Objects; | ||
import software.amazon.awssdk.annotations.Immutable; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.services.s3.S3CrtAsyncClientBuilder; | ||
import software.amazon.awssdk.utils.Validate; | ||
import software.amazon.awssdk.utils.builder.CopyableBuilder; | ||
import software.amazon.awssdk.utils.builder.ToCopyableBuilder; | ||
|
||
/** | ||
* Retry option configuration for AWS CRT-based S3 client. | ||
* | ||
* @see S3CrtAsyncClientBuilder#retryConfiguration | ||
*/ | ||
@SdkPublicApi | ||
@Immutable | ||
@ThreadSafe | ||
public final class S3CrtRetryConfiguration implements ToCopyableBuilder<S3CrtRetryConfiguration.Builder, | ||
S3CrtRetryConfiguration> { | ||
private final Integer numRetries; | ||
|
||
private S3CrtRetryConfiguration(DefaultBuilder builder) { | ||
Validate.notNull(builder.numRetries, "numRetries"); | ||
this.numRetries = builder.numRetries; | ||
} | ||
|
||
/** | ||
* Creates a default builder for {@link S3CrtRetryConfiguration}. | ||
*/ | ||
public static Builder builder() { | ||
return new S3CrtRetryConfiguration.DefaultBuilder(); | ||
} | ||
|
||
/** | ||
* Retrieve the {@link S3CrtRetryConfiguration.Builder#numRetries(Integer)} configured on the builder. | ||
*/ | ||
public Integer numRetries() { | ||
return numRetries; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
S3CrtRetryConfiguration that = (S3CrtRetryConfiguration) o; | ||
return Objects.equals(numRetries, that.numRetries); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return numRetries != null ? numRetries.hashCode() : 0; | ||
} | ||
|
||
@Override | ||
public Builder toBuilder() { | ||
return new S3CrtRetryConfiguration.DefaultBuilder(this); | ||
} | ||
|
||
public interface Builder extends CopyableBuilder<S3CrtRetryConfiguration.Builder, S3CrtRetryConfiguration> { | ||
|
||
/** | ||
* Configure the maximum number of times that a single request should be retried. | ||
* @param numRetries | ||
* @return The builder of the method chaining. | ||
*/ | ||
Builder numRetries(Integer numRetries); | ||
|
||
} | ||
|
||
private static final class DefaultBuilder implements Builder { | ||
private Integer numRetries; | ||
|
||
private DefaultBuilder() { | ||
} | ||
|
||
private DefaultBuilder(S3CrtRetryConfiguration crtRetryConfiguration) { | ||
this.numRetries = crtRetryConfiguration.numRetries; | ||
} | ||
|
||
@Override | ||
public Builder numRetries(Integer numRetries) { | ||
this.numRetries = numRetries; | ||
return this; | ||
} | ||
|
||
@Override | ||
public S3CrtRetryConfiguration build() { | ||
return new S3CrtRetryConfiguration(this); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../s3/src/test/java/software/amazon/awssdk/services/s3/crt/S3CrtRetryConfigurationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.s3.crt; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import org.junit.jupiter.api.Test; | ||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; | ||
import static org.assertj.core.api.Assertions.assertThatNullPointerException; | ||
|
||
|
||
public class S3CrtRetryConfigurationTest { | ||
|
||
@Test | ||
void equalsHashcode() { | ||
EqualsVerifier.forClass(S3CrtRetryConfiguration.class) | ||
.withRedefinedSuperclass() | ||
.verify(); | ||
} | ||
|
||
@Test | ||
void retryConfigurationWithNoMaxRetriesDefined(){ | ||
assertThatNullPointerException().isThrownBy(() ->S3CrtRetryConfiguration.builder().build()) | ||
.withMessage("numRetries"); | ||
} | ||
|
||
|
||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.