-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timeout retry stuck sdk client (#219)
## Description of change This PR adds timeout and retry logic to S3SdkObjectClient in case S3AsyncClinet cannot response to request for given time. #### Relevant issues AWS Java SDK V2 has an issue of getting stuck time to time: aws/aws-sdk-java-v2#5755 #### Does this contribution introduce any breaking changes to the existing APIs or behaviors? No #### Does this contribution introduce any new public APIs or behaviors? No #### How was the contribution tested? - Executed integration tests - Executed unit tests #### Does this contribution need a changelog entry? No #### Next Steps - In a follow-up PR, we need to make timeout configurable --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). --------- Co-authored-by: Erdogan Ozkoca <ozkoca@amazon.com>
- Loading branch information
Showing
7 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
42 changes: 42 additions & 0 deletions
42
...eam/src/test/java/software/amazon/s3/analyticsaccelerator/util/FakeStuckObjectClient.java
This file contains 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,42 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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.s3.analyticsaccelerator.util; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.TimeoutException; | ||
import software.amazon.s3.analyticsaccelerator.request.GetRequest; | ||
import software.amazon.s3.analyticsaccelerator.request.ObjectContent; | ||
import software.amazon.s3.analyticsaccelerator.request.StreamContext; | ||
|
||
public class FakeStuckObjectClient extends FakeObjectClient { | ||
|
||
/** | ||
* Instantiate a fake Object Client backed by some string as data. | ||
* | ||
* @param data the data making up the object | ||
*/ | ||
public FakeStuckObjectClient(String data) { | ||
super(data); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<ObjectContent> getObject( | ||
GetRequest getRequest, StreamContext streamContext) { | ||
CompletableFuture<ObjectContent> failedFuture = new CompletableFuture<>(); | ||
failedFuture.completeExceptionally(new TimeoutException("Request timed out")); | ||
return failedFuture; | ||
} | ||
} |