-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of sqs-common plugin and refactored sqs and s3 source (#…
…5361) * initial refactoring Signed-off-by: Jeremy Michael <[email protected]> * refactored sqs-source to use sqs-common Signed-off-by: Jeremy Michael <[email protected]> * refactored SqsWorker to use the common library Signed-off-by: Jeremy Michael <[email protected]> * minor changes Signed-off-by: Jeremy Michael <[email protected]> * another small fix Signed-off-by: Jeremy Michael <[email protected]> * added unit tests for sqs-common Signed-off-by: Jeremy Michael <[email protected]> * updated tests Signed-off-by: Jeremy Michael <[email protected]> --------- Signed-off-by: Jeremy Michael <[email protected]> Co-authored-by: Jeremy Michael <[email protected]>
- Loading branch information
Showing
18 changed files
with
581 additions
and
279 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
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.