-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lambda processor should retry for certain class of exceptions (#5320)
* lambda processor should retry for certain class of exceptions Signed-off-by: Srikanth Govindarajan <[email protected]> * Address Comment on complete codec Signed-off-by: Srikanth Govindarajan <[email protected]> * Add retryCondidition to lambda Client Signed-off-by: Srikanth Govindarajan <[email protected]> * Address comments Signed-off-by: Srikanth Govindarajan <[email protected]> * Address comments and add UT and IT Signed-off-by: Srikanth Govindarajan <[email protected]> * Address comment on completeCodec Signed-off-by: Srikanth Govindarajan <[email protected]> --------- Signed-off-by: Srikanth Govindarajan <[email protected]>
- Loading branch information
1 parent
8152c57
commit 70e8c8b
Showing
13 changed files
with
718 additions
and
9 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
23 changes: 23 additions & 0 deletions
23
...in/java/org/opensearch/dataprepper/plugins/lambda/common/util/CountingRetryCondition.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,23 @@ | ||
package org.opensearch.dataprepper.plugins.lambda.common.util; | ||
|
||
import software.amazon.awssdk.core.retry.RetryPolicyContext; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
//Used ONLY for tests | ||
public class CountingRetryCondition extends CustomLambdaRetryCondition { | ||
private final AtomicInteger retryCount = new AtomicInteger(0); | ||
|
||
@Override | ||
public boolean shouldRetry(RetryPolicyContext context) { | ||
boolean shouldRetry = super.shouldRetry(context); | ||
if (shouldRetry) { | ||
retryCount.incrementAndGet(); | ||
} | ||
return shouldRetry; | ||
} | ||
|
||
public int getRetryCount() { | ||
return retryCount.get(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ava/org/opensearch/dataprepper/plugins/lambda/common/util/CustomLambdaRetryCondition.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,17 @@ | ||
package org.opensearch.dataprepper.plugins.lambda.common.util; | ||
|
||
import software.amazon.awssdk.core.retry.conditions.RetryCondition; | ||
import software.amazon.awssdk.core.retry.RetryPolicyContext; | ||
|
||
public class CustomLambdaRetryCondition implements RetryCondition { | ||
|
||
@Override | ||
public boolean shouldRetry(RetryPolicyContext context) { | ||
Throwable exception = context.exception(); | ||
if (exception != null) { | ||
return LambdaRetryStrategy.isRetryableException(exception); | ||
} | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.