Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public GlueClient glue() {
return GlueClient.builder()
.applyMutation(this::applyAssumeRoleConfigurations)
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsClientProperties::applyRetryConfigurations)
.build();
}

Expand All @@ -99,6 +100,7 @@ public DynamoDbClient dynamo() {
.applyMutation(this::applyAssumeRoleConfigurations)
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsProperties::applyDynamoDbEndpointConfigurations)
.applyMutation(awsClientProperties::applyRetryConfigurations)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public GlueClient glue() {
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsProperties::applyGlueEndpointConfigurations)
.applyMutation(awsClientProperties::applyClientCredentialConfigurations)
.applyMutation(awsClientProperties::applyRetryConfigurations)
.build();
}

Expand All @@ -169,6 +170,7 @@ public DynamoDbClient dynamo() {
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsClientProperties::applyClientCredentialConfigurations)
.applyMutation(awsProperties::applyDynamoDbEndpointConfigurations)
.applyMutation(awsClientProperties::applyRetryConfigurations)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import org.apache.iceberg.TestHelpers;
import org.apache.iceberg.aws.lakeformation.LakeFormationAwsClientFactory;
import org.apache.iceberg.aws.s3.S3FileIOProperties;
Expand All @@ -38,7 +39,10 @@
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.awscore.AwsClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.retries.api.RetryStrategy;
import software.amazon.awssdk.retries.internal.DefaultAdaptiveRetryStrategy;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.glue.GlueClient;
import software.amazon.awssdk.services.glue.model.GetTablesRequest;
Expand Down Expand Up @@ -245,6 +249,42 @@ public void testWithClassDoesNotImplementCredentialsProvider() {
testProviderAndAssertThrownBy(providerClassName, containsMessage);
}

@Test
public void testGlueClientSetsAdaptiveRetryPolicy() {
AwsClientFactory factory =
getAwsClientFactoryByCredentialsProvider(DummyValidProvider.class.getName());
GlueClient glueClient = factory.glue();
assertAwsClientSetsAdaptiveRetryPolicy(glueClient);
}

@Test
public void testKmsClientSetsAdaptiveRetryPolicy() {
AwsClientFactory factory =
getAwsClientFactoryByCredentialsProvider(DummyValidProvider.class.getName());
KmsClient kmsClient = factory.kms();
assertAwsClientSetsAdaptiveRetryPolicy(kmsClient);
}

@Test
public void testDynamoClientSetsAdaptiveRetryPolicy() {
AwsClientFactory factory =
getAwsClientFactoryByCredentialsProvider(DummyValidProvider.class.getName());
DynamoDbClient dynamoClient = factory.dynamo();
assertAwsClientSetsAdaptiveRetryPolicy(dynamoClient);
}

/**
* Extract the retry strategy from an AwsClient object, then assert that it's set to the correct
* strategy. This enforces that we correctly applied the retry configurations to the client
* object.
*/
private void assertAwsClientSetsAdaptiveRetryPolicy(AwsClient client) {
Optional<RetryStrategy> retryStrategy =
client.serviceClientConfiguration().overrideConfiguration().retryStrategy();
assertThat(retryStrategy).isPresent();
assertThat(retryStrategy.get()).isInstanceOf(DefaultAdaptiveRetryStrategy.class);
}

private void testProviderAndAssertThrownBy(String providerClassName, String containsMessage) {
AwsClientFactory defaultAwsClientFactory =
getAwsClientFactoryByCredentialsProvider(providerClassName);
Expand Down