Skip to content

Commit

Permalink
Remove decreacated code from AWS module
Browse files Browse the repository at this point in the history
  • Loading branch information
ajantha-bhat committed Jan 21, 2024
1 parent a1b923f commit 45c24c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public GlueClient glue() {
.applyMutation(awsClientProperties::applyClientRegionConfiguration)
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsProperties::applyGlueEndpointConfigurations)
.applyMutation(awsProperties::applyClientCredentialConfigurations)
.applyMutation(awsClientProperties::applyClientCredentialConfigurations)
.build();
}

Expand All @@ -131,7 +131,7 @@ public KmsClient kms() {
return KmsClient.builder()
.applyMutation(awsClientProperties::applyClientRegionConfiguration)
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsProperties::applyClientCredentialConfigurations)
.applyMutation(awsClientProperties::applyClientCredentialConfigurations)
.build();
}

Expand All @@ -140,7 +140,7 @@ public DynamoDbClient dynamo() {
return DynamoDbClient.builder()
.applyMutation(awsClientProperties::applyClientRegionConfiguration)
.applyMutation(httpClientProperties::applyHttpClientConfigurations)
.applyMutation(awsProperties::applyClientCredentialConfigurations)
.applyMutation(awsClientProperties::applyClientCredentialConfigurations)
.applyMutation(awsProperties::applyDynamoDbEndpointConfigurations)
.build();
}
Expand Down
50 changes: 0 additions & 50 deletions aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.Serializable;
import java.net.URI;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -30,18 +29,15 @@
import org.apache.iceberg.common.DynMethods;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.relocated.com.google.common.base.Strings;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.util.PropertyUtil;
import org.apache.iceberg.util.SerializableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.core.client.builder.SdkClientBuilder;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain;
Expand Down Expand Up @@ -215,15 +211,13 @@ public class AwsProperties implements Serializable {
public static final String REST_SESSION_TOKEN = "rest.session-token";

private static final String HTTP_CLIENT_PREFIX = "http-client.";
private final Map<String, String> httpClientProperties;
private final Set<software.amazon.awssdk.services.sts.model.Tag> stsClientAssumeRoleTags;

private String clientAssumeRoleArn;
private String clientAssumeRoleExternalId;
private int clientAssumeRoleTimeoutSec;
private String clientAssumeRoleRegion;
private String clientAssumeRoleSessionName;
private String clientRegion;
private String clientCredentialsProvider;
private final Map<String, String> clientCredentialsProviderProperties;

Expand All @@ -235,7 +229,6 @@ public class AwsProperties implements Serializable {

private String dynamoDbTableName;
private String dynamoDbEndpoint;
private final Map<String, String> allProperties;

private String restSigningRegion;
private String restSigningName;
Expand All @@ -244,15 +237,13 @@ public class AwsProperties implements Serializable {
private String restSessionToken;

public AwsProperties() {
this.httpClientProperties = Collections.emptyMap();
this.stsClientAssumeRoleTags = Sets.newHashSet();

this.clientAssumeRoleArn = null;
this.clientAssumeRoleTimeoutSec = CLIENT_ASSUME_ROLE_TIMEOUT_SEC_DEFAULT;
this.clientAssumeRoleExternalId = null;
this.clientAssumeRoleRegion = null;
this.clientAssumeRoleSessionName = null;
this.clientRegion = null;
this.clientCredentialsProvider = null;
this.clientCredentialsProviderProperties = null;

Expand All @@ -265,15 +256,11 @@ public AwsProperties() {
this.dynamoDbEndpoint = null;
this.dynamoDbTableName = DYNAMODB_TABLE_NAME_DEFAULT;

this.allProperties = Maps.newHashMap();

this.restSigningName = REST_SIGNING_NAME_DEFAULT;
}

@SuppressWarnings("MethodLength")
public AwsProperties(Map<String, String> properties) {
this.httpClientProperties =
PropertyUtil.filterProperties(properties, key -> key.startsWith(HTTP_CLIENT_PREFIX));
this.stsClientAssumeRoleTags = toStsTags(properties, CLIENT_ASSUME_ROLE_TAGS_PREFIX);
this.clientAssumeRoleArn = properties.get(CLIENT_ASSUME_ROLE_ARN);
this.clientAssumeRoleTimeoutSec =
Expand All @@ -282,7 +269,6 @@ public AwsProperties(Map<String, String> properties) {
this.clientAssumeRoleExternalId = properties.get(CLIENT_ASSUME_ROLE_EXTERNAL_ID);
this.clientAssumeRoleRegion = properties.get(CLIENT_ASSUME_ROLE_REGION);
this.clientAssumeRoleSessionName = properties.get(CLIENT_ASSUME_ROLE_SESSION_NAME);
this.clientRegion = properties.get(AwsClientProperties.CLIENT_REGION);
this.clientCredentialsProvider =
properties.get(AwsClientProperties.CLIENT_CREDENTIALS_PROVIDER);
this.clientCredentialsProviderProperties =
Expand All @@ -307,8 +293,6 @@ public AwsProperties(Map<String, String> properties) {
this.dynamoDbTableName =
PropertyUtil.propertyAsString(properties, DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT);

this.allProperties = SerializableMap.copyOf(properties);

this.restSigningRegion = properties.get(REST_SIGNER_REGION);
this.restSigningName = properties.getOrDefault(REST_SIGNING_NAME, REST_SIGNING_NAME_DEFAULT);
this.restAccessKeyId = properties.get(REST_ACCESS_KEY_ID);
Expand Down Expand Up @@ -380,40 +364,6 @@ public void setDynamoDbTableName(String name) {
this.dynamoDbTableName = name;
}

/** @deprecated will be removed in 1.5.0, use {@link HttpClientProperties} instead */
@Deprecated
public Map<String, String> httpClientProperties() {
return httpClientProperties;
}

/**
* @deprecated will be removed in 1.5.0, use {@link AwsClientProperties#clientRegion()} instead
*/
@Deprecated
public String clientRegion() {
return clientRegion;
}

/**
* @deprecated will be removed in 1.5.0, use {@link AwsClientProperties#setClientRegion(String)}
* instead
*/
@Deprecated
public void setClientRegion(String clientRegion) {
this.clientRegion = clientRegion;
}

/**
* @deprecated will be removed in 1.5.0, use {@link
* AwsClientProperties#applyClientCredentialConfigurations(AwsClientBuilder)} instead
*/
@Deprecated
public <T extends AwsClientBuilder> void applyClientCredentialConfigurations(T builder) {
if (!Strings.isNullOrEmpty(this.clientCredentialsProvider)) {
builder.credentialsProvider(credentialsProvider(this.clientCredentialsProvider));
}
}

/**
* Override the endpoint for a glue client.
*
Expand Down
25 changes: 9 additions & 16 deletions aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*/
package org.apache.iceberg.aws;

import static org.apache.iceberg.aws.AwsProperties.DYNAMODB_TABLE_NAME;
import static org.apache.iceberg.aws.AwsProperties.GLUE_CATALOG_ID;

import java.io.IOException;
import java.util.Collections;
import org.apache.iceberg.TestHelpers;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.assertj.core.api.Assertions;
Expand All @@ -29,22 +31,13 @@ public class TestAwsProperties {

@Test
public void testKryoSerialization() throws IOException {
AwsProperties awsProperties = new AwsProperties();
AwsProperties deSerializedAwsProperties =
TestHelpers.KryoHelpers.roundTripSerialize(awsProperties);
Assertions.assertThat(deSerializedAwsProperties.httpClientProperties())
.isEqualTo(awsProperties.httpClientProperties());

AwsProperties awsPropertiesWithProps = new AwsProperties(ImmutableMap.of("a", "b"));
AwsProperties awsPropertiesWithProps =
new AwsProperties(ImmutableMap.of(GLUE_CATALOG_ID, "foo", DYNAMODB_TABLE_NAME, "ice"));
AwsProperties deSerializedAwsPropertiesWithProps =
TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps);
Assertions.assertThat(deSerializedAwsPropertiesWithProps.httpClientProperties())
.isEqualTo(awsProperties.httpClientProperties());

AwsProperties awsPropertiesWithEmptyProps = new AwsProperties(Collections.emptyMap());
AwsProperties deSerializedAwsPropertiesWithEmptyProps =
TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps);
Assertions.assertThat(deSerializedAwsPropertiesWithEmptyProps.httpClientProperties())
.isEqualTo(awsProperties.httpClientProperties());
Assertions.assertThat(deSerializedAwsPropertiesWithProps.glueCatalogId())
.isEqualTo(awsPropertiesWithProps.glueCatalogId());
Assertions.assertThat(deSerializedAwsPropertiesWithProps.dynamoDbTableName())
.isEqualTo(awsPropertiesWithProps.dynamoDbTableName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public void testUrlConnectionOverrideConfigurations() {
properties.put(HttpClientProperties.URLCONNECTION_CONNECTION_TIMEOUT_MS, "80");
properties.put(HttpClientProperties.APACHE_SOCKET_TIMEOUT_MS, "100");
properties.put(HttpClientProperties.APACHE_CONNECTION_TIMEOUT_MS, "200");
AwsProperties awsProperties = new AwsProperties(properties);
UrlConnectionHttpClientConfigurations urlConnectionHttpClientConfigurations =
UrlConnectionHttpClientConfigurations.create(awsProperties.httpClientProperties());
UrlConnectionHttpClientConfigurations.create(properties);
UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder =
UrlConnectionHttpClient.builder();
UrlConnectionHttpClient.Builder spyUrlConnectionHttpClientBuilder =
Expand All @@ -51,10 +50,8 @@ public void testUrlConnectionOverrideConfigurations() {

@Test
public void testUrlConnectionDefaultConfigurations() {
Map<String, String> properties = Maps.newHashMap();
AwsProperties awsProperties = new AwsProperties(properties);
UrlConnectionHttpClientConfigurations urlConnectionHttpClientConfigurations =
UrlConnectionHttpClientConfigurations.create(awsProperties.httpClientProperties());
UrlConnectionHttpClientConfigurations.create(Maps.newHashMap());
UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder =
UrlConnectionHttpClient.builder();
UrlConnectionHttpClient.Builder spyUrlConnectionHttpClientBuilder =
Expand Down Expand Up @@ -83,9 +80,8 @@ public void testApacheOverrideConfigurations() {
properties.put(HttpClientProperties.APACHE_MAX_CONNECTIONS, "104");
properties.put(HttpClientProperties.APACHE_TCP_KEEP_ALIVE_ENABLED, "true");
properties.put(HttpClientProperties.APACHE_USE_IDLE_CONNECTION_REAPER_ENABLED, "false");
AwsProperties awsProperties = new AwsProperties(properties);
ApacheHttpClientConfigurations apacheHttpClientConfigurations =
ApacheHttpClientConfigurations.create(awsProperties.httpClientProperties());
ApacheHttpClientConfigurations.create(properties);
ApacheHttpClient.Builder apacheHttpClientBuilder = ApacheHttpClient.builder();
ApacheHttpClient.Builder spyApacheHttpClientBuilder = Mockito.spy(apacheHttpClientBuilder);

Expand All @@ -104,10 +100,8 @@ public void testApacheOverrideConfigurations() {

@Test
public void testApacheDefaultConfigurations() {
Map<String, String> properties = Maps.newHashMap();
AwsProperties awsProperties = new AwsProperties(properties);
ApacheHttpClientConfigurations apacheHttpClientConfigurations =
ApacheHttpClientConfigurations.create(awsProperties.httpClientProperties());
ApacheHttpClientConfigurations.create(Maps.newHashMap());
ApacheHttpClient.Builder apacheHttpClientBuilder = ApacheHttpClient.builder();
ApacheHttpClient.Builder spyApacheHttpClientBuilder = Mockito.spy(apacheHttpClientBuilder);

Expand Down

0 comments on commit 45c24c0

Please sign in to comment.