-
Notifications
You must be signed in to change notification settings - Fork 214
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
Implementation of sqs-common plugin and refactored sqs and s3 source #5361
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0488995
initial refactoring
2ad47a4
refactored sqs-source to use sqs-common
ece7d2c
refactored SqsWorker to use the common library
d97f8f8
minor changes
3f4f1ae
another small fix
dbc0b51
added unit tests for sqs-common
da2d157
updated tests
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
} | ||
|
||
dependencies { | ||
implementation project(':data-prepper-api') | ||
implementation project(':data-prepper-plugins:buffer-common') | ||
implementation project(':data-prepper-plugins:common') | ||
implementation libs.armeria.core | ||
implementation project(':data-prepper-plugins:aws-plugin-api') | ||
implementation 'software.amazon.awssdk:sqs' | ||
implementation 'software.amazon.awssdk:arns' | ||
implementation 'software.amazon.awssdk:sts' | ||
implementation 'io.micrometer:micrometer-core' | ||
implementation 'com.fasterxml.jackson.core:jackson-annotations' | ||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' | ||
implementation 'org.hibernate.validator:hibernate-validator:8.0.1.Final' | ||
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' | ||
testImplementation project(':data-prepper-plugins:blocking-buffer') | ||
} | ||
test { | ||
useJUnitPlatform() | ||
} |
27 changes: 27 additions & 0 deletions
27
...common/src/main/java/org/opensearch/dataprepper/plugins/source/sqs/common/SqsBackoff.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,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.sqs.common; | ||
|
||
import com.linecorp.armeria.client.retry.Backoff; | ||
import java.time.Duration; | ||
|
||
public final class SqsBackoff { | ||
private static final long INITIAL_DELAY_MILLIS = Duration.ofSeconds(20).toMillis(); | ||
private static final long MAX_DELAY_MILLIS = Duration.ofMinutes(5).toMillis(); | ||
private static final double JITTER_RATE = 0.20; | ||
|
||
private SqsBackoff() {} | ||
|
||
public static Backoff createExponentialBackoff() { | ||
return Backoff.exponential(INITIAL_DELAY_MILLIS, MAX_DELAY_MILLIS) | ||
.withJitter(JITTER_RATE) | ||
.withMaxAttempts(Integer.MAX_VALUE); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../src/main/java/org/opensearch/dataprepper/plugins/source/sqs/common/SqsClientFactory.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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.sqs.common; | ||
|
||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; | ||
import software.amazon.awssdk.core.retry.RetryPolicy; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.sqs.SqsClient; | ||
|
||
/** | ||
* A common factory to create SQS clients | ||
*/ | ||
public final class SqsClientFactory { | ||
|
||
private SqsClientFactory() { | ||
} | ||
|
||
public static SqsClient createSqsClient( | ||
final Region region, | ||
final AwsCredentialsProvider credentialsProvider) { | ||
|
||
return SqsClient.builder() | ||
.region(region) | ||
.credentialsProvider(credentialsProvider) | ||
.overrideConfiguration(ClientOverrideConfiguration.builder() | ||
.retryPolicy(RetryPolicy.builder().numRetries(5).build()) | ||
.build()) | ||
.build(); | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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 possibility that this Backoff strategy could be different for S3 source vs sqs source?
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 Backoff strategy is currently the same for both S3 and SQS sources, as both handle SQS polling. If needed, we can extend SqsBackoff in the future to support options like linear backoff.