From 5d68871758b37cdea3ffd479a27667fe3f4c275b Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Thu, 17 Oct 2019 09:53:12 +0200 Subject: [PATCH] Cleaned apache config section, http client dependencies as optional --- docs/src/main/asciidoc/dynamodb-guide.adoc | 8 +-- extensions/amazon-dynamodb/deployment/pom.xml | 21 +++++++ .../deployment/DynamodbProcessor.java | 49 +++++++++------ .../resources/async-full-config.properties | 8 +-- .../async-tls-filestore-config.properties | 2 +- .../default-credentials-config.properties | 2 +- ...ocess-credentials-broken-config.properties | 2 +- .../profile-credentials-config.properties | 2 +- ...tatic-credentials-broken-config.properties | 2 +- .../sync-apache-broken-config.properties | 4 +- ...sync-apache-broken-proxy-config.properties | 6 +- .../sync-apache-full-config.properties | 34 +++++------ .../sync-urlconn-full-config.properties | 8 +-- extensions/amazon-dynamodb/runtime/pom.xml | 3 + .../runtime/DynamodbClientProducer.java | 33 +++++----- .../runtime/SyncHttpClientConfig.java | 61 +------------------ integration-tests/amazon-dynamodb/pom.xml | 9 +++ .../src/main/resources/application.properties | 2 +- 18 files changed, 121 insertions(+), 135 deletions(-) diff --git a/docs/src/main/asciidoc/dynamodb-guide.adoc b/docs/src/main/asciidoc/dynamodb-guide.adoc index d1f67c3750729a..259f574b9cba53 100644 --- a/docs/src/main/asciidoc/dynamodb-guide.adoc +++ b/docs/src/main/asciidoc/dynamodb-guide.adoc @@ -326,24 +326,24 @@ If you're going to use a local DynamoDB instance, configure it as follows: quarkus.dynamodb.endpoint-override=http://localhost:8000 quarkus.dynamodb.aws.region=eu-central-1 -quarkus.dynamodb.aws.credentials.type=STATIC +quarkus.dynamodb.aws.credentials.type=static quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret ---- - `quarkus.dynamodb.aws.region` - It's required by the client, but since you're using a local DynamoDB instance you can pick any valid AWS region. -- `quarkus.dynamodb.aws.credentials.type` - Set `STATIC` credentials provider with any values for `access-key-id` and `secret-access-key` +- `quarkus.dynamodb.aws.credentials.type` - Set `static` credentials provider with any values for `access-key-id` and `secret-access-key` - `quarkus.dynamodb.endpoint-override` - Override the DynamoDB client to use a local instance instead of an AWS service If you want to work with an AWS account, you'd need to set it with: [source,properties] ---- quarkus.dynamodb.aws.region= -quarkus.dynamodb.aws.credentials.type=DEFAULT +quarkus.dynamodb.aws.credentials.type=default ---- - `quarkus.dynamodb.aws.region` you should set it to the region where you provisioned the DynamoDB table, -- `quarkus.dynamodb.aws.credentials.type` - use the `DEFAULT` credentials provider chain that looks for credentials in this order: +- `quarkus.dynamodb.aws.credentials.type` - use the `default` credentials provider chain that looks for credentials in this order: - Java System Properties - `aws.accessKeyId` and `aws.secretKey` * Environment Variables - `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` * Credential profiles file at the default location (`~/.aws/credentials`) shared by all AWS SDKs and the AWS CLI diff --git a/extensions/amazon-dynamodb/deployment/pom.xml b/extensions/amazon-dynamodb/deployment/pom.xml index e9d56137a24718..f7e84adbc119df 100644 --- a/extensions/amazon-dynamodb/deployment/pom.xml +++ b/extensions/amazon-dynamodb/deployment/pom.xml @@ -42,6 +42,27 @@ rest-assured test + + software.amazon.awssdk + netty-nio-client + test + + + software.amazon.awssdk + url-connection-client + test + + + software.amazon.awssdk + apache-client + test + + + commons-logging + commons-logging + + + diff --git a/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java b/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java index 00b35b509d0785..117787ef2e80c0 100644 --- a/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java +++ b/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.stream.Collectors; +import javax.enterprise.inject.spi.DeploymentException; + import org.jboss.jandex.DotName; import org.jboss.jandex.Type; @@ -17,6 +19,7 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.ApplicationIndexBuildItem; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; @@ -38,10 +41,7 @@ import io.quarkus.dynamodb.runtime.TlsManagersProviderType; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.SdkHttpService; -import software.amazon.awssdk.http.apache.ApacheSdkHttpService; import software.amazon.awssdk.http.async.SdkAsyncHttpService; -import software.amazon.awssdk.http.nio.netty.NettySdkAsyncHttpService; -import software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService; import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.utils.StringUtils; @@ -49,6 +49,10 @@ public class DynamodbProcessor { public static final String AWS_SDK_APPLICATION_ARCHIVE_MARKERS = "software/amazon/awssdk"; + private static final String APACHE_HTTP_SERVICE = "software.amazon.awssdk.http.apache.ApacheSdkHttpService"; + private static final String NETTY_HTTP_SERVICE = "software.amazon.awssdk.http.nio.netty.NettySdkAsyncHttpService"; + private static final String URL_HTTP_SERVICE = "software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService"; + private static final List INTERCEPTOR_PATHS = Arrays.asList( "software/amazon/awssdk/global/handlers/execution.interceptors", "software/amazon/awssdk/services/dynamodb/execution.interceptors"); @@ -95,7 +99,8 @@ void setup(CombinedIndexBuildItem combinedIndexBuildItem, @BuildStep DynamodbClientBuildItem analyzeDynamodbClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, BuildProducer serviceProvider, - BuildProducer proxyDefinition) { + BuildProducer proxyDefinition, + ApplicationIndexBuildItem appIndex) { boolean createSyncClient = false; boolean createAsyncClient = false; @@ -115,31 +120,39 @@ DynamodbClientBuildItem analyzeDynamodbClientInjectionPoints(BeanRegistrationPha if (createSyncClient) { if (config.syncClient.type == SyncClientType.APACHE) { + checkClasspath(APACHE_HTTP_SERVICE, "apache-client"); + //Register Apache client as sync client - proxyDefinition - .produce(new SubstrateProxyDefinitionBuildItem("org.apache.http.conn.HttpClientConnectionManager", + proxyDefinition.produce( + new SubstrateProxyDefinitionBuildItem("org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "software.amazon.awssdk.http.apache.internal.conn.Wrapped")); - serviceProvider.produce( - new ServiceProviderBuildItem(SdkHttpService.class.getName(), ApacheSdkHttpService.class.getName())); + serviceProvider.produce(new ServiceProviderBuildItem(SdkHttpService.class.getName(), APACHE_HTTP_SERVICE)); } else { - serviceProvider.produce( - new ServiceProviderBuildItem(SdkHttpService.class.getName(), - UrlConnectionSdkHttpService.class.getName())); + checkClasspath(URL_HTTP_SERVICE, "url-connection-client"); + serviceProvider.produce(new ServiceProviderBuildItem(SdkHttpService.class.getName(), URL_HTTP_SERVICE)); } } if (createAsyncClient) { + checkClasspath(NETTY_HTTP_SERVICE, "netty-nio-client"); //Register netty as async client - serviceProvider.produce( - new ServiceProviderBuildItem(SdkAsyncHttpService.class.getName(), - NettySdkAsyncHttpService.class.getName())); + serviceProvider.produce(new ServiceProviderBuildItem(SdkAsyncHttpService.class.getName(), NETTY_HTTP_SERVICE)); } return new DynamodbClientBuildItem(createSyncClient, createAsyncClient); } + private void checkClasspath(String className, String dependencyName) { + try { + Class.forName(className, true, Thread.currentThread().getContextClassLoader()); + } catch (ClassNotFoundException e) { + throw new DeploymentException( + "Missing 'software.amazon.awssdk:" + dependencyName + "' dependency on the classpath"); + } + } + @BuildStep @Record(ExecutionTime.RUNTIME_INIT) void buildClients(DynamodbClientBuildItem clientBuildItem, DynamodbRecorder recorder, @@ -203,16 +216,16 @@ private static void checkConfig(DynamodbConfig config, List knownInterce private static void checkSyncClientConfig(SyncHttpClientConfig syncClient) { if (syncClient.type == SyncClientType.APACHE) { - if (syncClient.apacheHttp.maxConnections <= 0) { + if (syncClient.apache.maxConnections <= 0) { throw new ConfigurationError("quarkus.dynamodb.sync-client.max-connections may not be negative or zero."); } - if (syncClient.apacheHttp.proxy != null && syncClient.apacheHttp.proxy.enabled) { - URI proxyEndpoint = syncClient.apacheHttp.proxy.endpoint; + if (syncClient.apache.proxy != null && syncClient.apache.proxy.enabled) { + URI proxyEndpoint = syncClient.apache.proxy.endpoint; if (proxyEndpoint != null) { validateProxyEndpoint(proxyEndpoint, "sync"); } } - validateTlsManagersProvider(syncClient.apacheHttp.tlsManagersProvider, "sync"); + validateTlsManagersProvider(syncClient.apache.tlsManagersProvider, "sync"); } } diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/async-full-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/async-full-config.properties index d11804c004250a..90e4f26c69c636 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/async-full-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/async-full-config.properties @@ -2,7 +2,7 @@ quarkus.dynamodb.enable-endpoint-discovery=false quarkus.dynamodb.endpoint-override=http://localhost:8000 quarkus.dynamodb.aws.region=us-east-1 -quarkus.dynamodb.aws.credentials.type=STATIC +quarkus.dynamodb.aws.credentials.type=static quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret @@ -15,13 +15,13 @@ quarkus.dynamodb.async-client.connection-acquisition-timeout=0.01S quarkus.dynamodb.async-client.connection-time-to-live=0.01S quarkus.dynamodb.async-client.connection-max-idle-time=0.01S quarkus.dynamodb.async-client.use-idle-connection-reaper=false -quarkus.dynamodb.async-client.protocol = HTTP1_1 +quarkus.dynamodb.async-client.protocol = http1-1 quarkus.dynamodb.async-client.max-http2-streams = 10 -quarkus.dynamodb.async-client.ssl-provider = JDK +quarkus.dynamodb.async-client.ssl-provider = jdk quarkus.dynamodb.async-client.event-loop.override = true quarkus.dynamodb.async-client.event-loop.number-of-threads = 5 quarkus.dynamodb.async-client.event-loop.thread-name-prefix = Quarkus-Netty-EventLoop- quarkus.dynamodb.async-client.proxy.enabled = true quarkus.dynamodb.async-client.proxy.endpoint = http://127.1.1.1 quarkus.dynamodb.async-client.proxy.non-proxy-hosts = localhost, hostlocal -quarkus.dynamodb.async-client.tls-managers-provider.type=SYSTEM_PROPERTY \ No newline at end of file +quarkus.dynamodb.async-client.tls-managers-provider.type=system-property \ No newline at end of file diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/async-tls-filestore-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/async-tls-filestore-config.properties index 4c69f6fe612574..65ffaa596619f4 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/async-tls-filestore-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/async-tls-filestore-config.properties @@ -1,6 +1,6 @@ quarkus.dynamodb.aws.region=us-east-1 -quarkus.dynamodb.async-client.tls-managers-provider.type=FILE_STORE +quarkus.dynamodb.async-client.tls-managers-provider.type=file-store quarkus.dynamodb.async-client.tls-managers-provider.file-store.path=/tmp/file.key quarkus.dynamodb.async-client.tls-managers-provider.file-store.type=pkcs11 quarkus.dynamodb.async-client.tls-managers-provider.file-store.password=thePassword \ No newline at end of file diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/default-credentials-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/default-credentials-config.properties index 33ffae4072d2d4..8a7fad0a7de214 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/default-credentials-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/default-credentials-config.properties @@ -1,6 +1,6 @@ quarkus.dynamodb.aws.region=us-east-2 -quarkus.dynamodb.aws.credentials.type=DEFAULT +quarkus.dynamodb.aws.credentials.type=default quarkus.dynamodb.aws.credentials.default-provider.async-credential-update-enabled=true quarkus.dynamodb.aws.credentials.default-provider.reuse-last-provider-enabled=true diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/process-credentials-broken-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/process-credentials-broken-config.properties index 92f9bbe05864e4..84fedaa7dfdf79 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/process-credentials-broken-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/process-credentials-broken-config.properties @@ -1,2 +1,2 @@ -quarkus.dynamodb.aws.credentials.type=PROCESS +quarkus.dynamodb.aws.credentials.type=process diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/profile-credentials-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/profile-credentials-config.properties index f565b1bf64b595..2ea33444d9cb1e 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/profile-credentials-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/profile-credentials-config.properties @@ -1,5 +1,5 @@ quarkus.dynamodb.aws.region=us-east-2 -quarkus.dynamodb.aws.credentials.type=PROFILE +quarkus.dynamodb.aws.credentials.type=profile quarkus.dynamodb.aws.credentials.profile-provider.profile-name=myprofile diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/static-credentials-broken-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/static-credentials-broken-config.properties index 8603551e320c5d..72eb83daa36813 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/static-credentials-broken-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/static-credentials-broken-config.properties @@ -1 +1 @@ -quarkus.dynamodb.aws.credentials.type=STATIC \ No newline at end of file +quarkus.dynamodb.aws.credentials.type=static \ No newline at end of file diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-config.properties index cbf663f84a3e38..2c5b0fc5861f2b 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-config.properties @@ -1,4 +1,4 @@ -quarkus.dynamodb.sync-client.type = APACHE -quarkus.dynamodb.sync-client.max-connections = -10 +quarkus.dynamodb.sync-client.type = apache +quarkus.dynamodb.sync-client.apache.max-connections = -10 diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-proxy-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-proxy-config.properties index 6b7ba246a0e576..502389b51e71c6 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-proxy-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-broken-proxy-config.properties @@ -1,6 +1,6 @@ -quarkus.dynamodb.sync-client.type = APACHE -quarkus.dynamodb.sync-client.proxy.enabled = true -quarkus.dynamodb.sync-client.proxy.endpoint = http://user:name@127.1.1.1?foo=bar +quarkus.dynamodb.sync-client.type = apache +quarkus.dynamodb.sync-client.apache.proxy.enabled = true +quarkus.dynamodb.sync-client.apache.proxy.endpoint = http://user:name@127.1.1.1?foo=bar diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-full-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-full-config.properties index afed8f4b7aee23..eba7c043114684 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-full-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-apache-full-config.properties @@ -2,27 +2,27 @@ quarkus.dynamodb.enable-endpoint-discovery=false quarkus.dynamodb.endpoint-override=http://localhost:8000 quarkus.dynamodb.aws.region=us-east-2 -quarkus.dynamodb.aws.credentials.type=STATIC +quarkus.dynamodb.aws.credentials.type=static quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret -quarkus.dynamodb.sync-client.type = APACHE +quarkus.dynamodb.sync-client.type=apache quarkus.dynamodb.sync-client.socket-timeout = 0.100S quarkus.dynamodb.sync-client.connection-timeout = 0.100S -quarkus.dynamodb.sync-client.connection-acquisition-timeout = 0.100S -quarkus.dynamodb.sync-client.connection-max-idle-time = 0.100S -quarkus.dynamodb.sync-client.connection-time-to-live = 0.100S -quarkus.dynamodb.sync-client.max-connections = 10 -quarkus.dynamodb.sync-client.expect-continue-enabled = true -quarkus.dynamodb.sync-client.use-idle-connection-reaper = true -quarkus.dynamodb.sync-client.proxy.enabled = true -quarkus.dynamodb.sync-client.proxy.endpoint = http://127.1.1.1 -quarkus.dynamodb.sync-client.proxy.username = foo -quarkus.dynamodb.sync-client.proxy.password = bar -quarkus.dynamodb.sync-client.proxy.ntlm-domain = foo-domainn -quarkus.dynamodb.sync-client.proxy.ntlm-workstation = foo-workstation -quarkus.dynamodb.sync-client.proxy.preemptive-basic-authentication-enabled = true -quarkus.dynamodb.sync-client.proxy.non-proxy-hosts = localhost, hostlocal -quarkus.dynamodb.sync-client.tls-managers-provider.type=SYSTEM_PROPERTY +quarkus.dynamodb.sync-client.apache.connection-acquisition-timeout = 0.100S +quarkus.dynamodb.sync-client.apache.connection-max-idle-time = 0.100S +quarkus.dynamodb.sync-client.apache.connection-time-to-live = 0.100S +quarkus.dynamodb.sync-client.apache.max-connections = 10 +quarkus.dynamodb.sync-client.apache.expect-continue-enabled = true +quarkus.dynamodb.sync-client.apache.use-idle-connection-reaper = true +quarkus.dynamodb.sync-client.apache.proxy.enabled = true +quarkus.dynamodb.sync-client.apache.proxy.endpoint = http://127.1.1.1 +quarkus.dynamodb.sync-client.apache.proxy.username = foo +quarkus.dynamodb.sync-client.apache.proxy.password = bar +quarkus.dynamodb.sync-client.apache.proxy.ntlm-domain = foo-domainn +quarkus.dynamodb.sync-client.apache.proxy.ntlm-workstation = foo-workstation +quarkus.dynamodb.sync-client.apache.proxy.preemptive-basic-authentication-enabled = true +quarkus.dynamodb.sync-client.apache.proxy.non-proxy-hosts = localhost, hostlocal +quarkus.dynamodb.sync-client.apache.tls-managers-provider.type=system-property diff --git a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-urlconn-full-config.properties b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-urlconn-full-config.properties index be217010ffed55..50bddab66d55f6 100644 --- a/extensions/amazon-dynamodb/deployment/src/test/resources/sync-urlconn-full-config.properties +++ b/extensions/amazon-dynamodb/deployment/src/test/resources/sync-urlconn-full-config.properties @@ -2,12 +2,12 @@ quarkus.dynamodb.enable-endpoint-discovery=false quarkus.dynamodb.endpoint-override=http://localhost:8000 quarkus.dynamodb.aws.region=us-east-2 -quarkus.dynamodb.aws.credentials.type=STATIC +quarkus.dynamodb.aws.credentials.type=static quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret -quarkus.dynamodb.sync-client.type = URL -quarkus.dynamodb.sync-client.socket-timeout = 0.100S -quarkus.dynamodb.sync-client.connection-timeout = 0.100S +quarkus.dynamodb.sync-client.type=url +quarkus.dynamodb.sync-client.socket-timeout=0.100S +quarkus.dynamodb.sync-client.connection-timeout=0.100S diff --git a/extensions/amazon-dynamodb/runtime/pom.xml b/extensions/amazon-dynamodb/runtime/pom.xml index 3e605efcb17102..1a33c3b9dad154 100644 --- a/extensions/amazon-dynamodb/runtime/pom.xml +++ b/extensions/amazon-dynamodb/runtime/pom.xml @@ -34,14 +34,17 @@ software.amazon.awssdk netty-nio-client + true software.amazon.awssdk url-connection-client + true software.amazon.awssdk apache-client + true commons-logging diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java index c94040ae7b408f..940aa53c93cb52 100644 --- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java +++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java @@ -11,7 +11,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.quarkus.dynamodb.runtime.SyncHttpClientConfig.ApacheHttpClientConfig; import io.quarkus.dynamodb.runtime.SyncHttpClientConfig.SyncClientType; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.core.client.builder.SdkClientBuilder; @@ -128,31 +127,29 @@ private ApacheHttpClient.Builder createApacheClientBuilder(SyncHttpClientConfig builder.connectionTimeout(config.connectionTimeout); builder.socketTimeout(config.socketTimeout); - ApacheHttpClientConfig apacheHttpClientConfig = config.apacheHttp; + builder.connectionAcquisitionTimeout(config.apache.connectionAcquisitionTimeout); + builder.connectionMaxIdleTime(config.apache.connectionMaxIdleTime); + config.apache.connectionTimeToLive.ifPresent(builder::connectionTimeToLive); + builder.expectContinueEnabled(config.apache.expectContinueEnabled); + builder.maxConnections(config.apache.maxConnections); + builder.useIdleConnectionReaper(config.apache.useIdleConnectionReaper); - builder.connectionAcquisitionTimeout(apacheHttpClientConfig.connectionAcquisitionTimeout); - builder.connectionMaxIdleTime(apacheHttpClientConfig.connectionMaxIdleTime); - apacheHttpClientConfig.connectionTimeToLive.ifPresent(builder::connectionTimeToLive); - builder.expectContinueEnabled(apacheHttpClientConfig.expectContinueEnabled); - builder.maxConnections(apacheHttpClientConfig.maxConnections); - builder.useIdleConnectionReaper(apacheHttpClientConfig.useIdleConnectionReaper); - - if (apacheHttpClientConfig.proxy.enabled) { + if (config.apache.proxy.enabled) { ProxyConfiguration.Builder proxyBuilder = ProxyConfiguration.builder() - .endpoint(apacheHttpClientConfig.proxy.endpoint); - apacheHttpClientConfig.proxy.username.ifPresent(proxyBuilder::username); - apacheHttpClientConfig.proxy.password.ifPresent(proxyBuilder::password); - apacheHttpClientConfig.proxy.nonProxyHosts.forEach(proxyBuilder::addNonProxyHost); - apacheHttpClientConfig.proxy.ntlmDomain.ifPresent(proxyBuilder::ntlmDomain); - apacheHttpClientConfig.proxy.ntlmWorkstation.ifPresent(proxyBuilder::ntlmWorkstation); - apacheHttpClientConfig.proxy.preemptiveBasicAuthenticationEnabled + .endpoint(config.apache.proxy.endpoint); + config.apache.proxy.username.ifPresent(proxyBuilder::username); + config.apache.proxy.password.ifPresent(proxyBuilder::password); + config.apache.proxy.nonProxyHosts.forEach(proxyBuilder::addNonProxyHost); + config.apache.proxy.ntlmDomain.ifPresent(proxyBuilder::ntlmDomain); + config.apache.proxy.ntlmWorkstation.ifPresent(proxyBuilder::ntlmWorkstation); + config.apache.proxy.preemptiveBasicAuthenticationEnabled .ifPresent(proxyBuilder::preemptiveBasicAuthenticationEnabled); builder.proxyConfiguration(proxyBuilder.build()); } builder.tlsKeyManagersProvider( - apacheHttpClientConfig.tlsManagersProvider.type.create(apacheHttpClientConfig.tlsManagersProvider)); + config.apache.tlsManagersProvider.type.create(config.apache.tlsManagersProvider)); return builder; } diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java index 2e779908fffe86..f1cabe0217d2ba 100644 --- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java +++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java @@ -13,18 +13,12 @@ public class SyncHttpClientConfig { /** * Type of the sync HTTP client implementation - * - *

- * Accepted values are `URL` or `APACHE` */ @ConfigItem(defaultValue = "url") public SyncClientType type; /** * The maximum amount of time to establish a connection before timing out. - * - *

- * Used by `URL` and `APACHE` clients */ @ConfigItem(defaultValue = "2S") public Duration connectionTimeout; @@ -33,9 +27,6 @@ public class SyncHttpClientConfig { * The amount of time to wait for data to be transferred over an established, open connection before the connection is * timed * out. - * - *

- * Used by `URL` and `APACHE` clients */ @ConfigItem(defaultValue = "30S") public Duration socketTimeout; @@ -43,35 +34,26 @@ public class SyncHttpClientConfig { /** * Apache HTTP client additional configuration */ - @ConfigItem(name = ConfigItem.PARENT) - public ApacheHttpClientConfig apacheHttp; + @ConfigItem + public ApacheHttpClientConfig apache; @ConfigGroup public static class ApacheHttpClientConfig { /** * The amount of time to wait when acquiring a connection from the pool before giving up and timing out. - * - *

- * Used by `APACHE` client only */ @ConfigItem(defaultValue = "10S") public Duration connectionAcquisitionTimeout; /** * The maximum amount of time that a connection should be allowed to remain open while idle. - * - *

- * Used by `APACHE` client only */ @ConfigItem(defaultValue = "60S") public Duration connectionMaxIdleTime; /** * The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional connectionTimeToLive; @@ -80,18 +62,12 @@ public static class ApacheHttpClientConfig { * The maximum number of connections allowed in the connection pool. *

* Each built HTTP client has its own private connection pool. - * - *

- * Used by `APACHE` client only */ @ConfigItem(defaultValue = "50") public int maxConnections; /** * Whether the client should send an HTTP expect-continue handshake before each request. - * - *

- * Used by `APACHE` client only */ @ConfigItem(defaultValue = "true") public boolean expectContinueEnabled; @@ -102,27 +78,18 @@ public static class ApacheHttpClientConfig { * When enabled, connections left idling for longer than `quarkus.dynamodb.sync-client.connection-max-idle-time` will be * closed. * This will not close connections currently in use. - * - *

- * Used by `APACHE` client only */ @ConfigItem(defaultValue = "true") public boolean useIdleConnectionReaper; /** * HTTP proxy configuration - * - *

- * Used by `APACHE` client only */ @ConfigItem public HttpClientProxyConfiguration proxy; /** * TLS Managers provider configuration - * - *

- * Used by `APACHE` client only */ @ConfigItem public TlsManagersProviderConfig tlsManagersProvider; @@ -132,9 +99,6 @@ public static class HttpClientProxyConfiguration { /** * Enable HTTP proxy - * - *

- * Used by `APACHE` client only */ @ConfigItem public boolean enabled; @@ -144,63 +108,42 @@ public static class HttpClientProxyConfiguration { *

* Currently, the endpoint is limited to a host and port. Any other URI components will result in an exception being * raised. - * - *

- * Used by `APACHE` client only */ @ConfigItem public URI endpoint; /** * The username to use when connecting through a proxy. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional username; /** * The password to use when connecting through a proxy. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional password; /** * For NTLM proxies - the Windows domain name to use when authenticating with the proxy. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional ntlmDomain; /** * For NTLM proxies - the Windows workstation name to use when authenticating with the proxy. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional ntlmWorkstation; /** * Whether to attempt to authenticate preemptively against the proxy server using basic authentication. - * - *

- * Used by `APACHE` client only */ @ConfigItem public Optional preemptiveBasicAuthenticationEnabled; /** * The hosts that the client is allowed to access without going through the proxy. - * - *

- * Used by `APACHE` client only */ @ConfigItem public List nonProxyHosts; diff --git a/integration-tests/amazon-dynamodb/pom.xml b/integration-tests/amazon-dynamodb/pom.xml index 1efbccece9f7d0..51f0a5da3f347d 100644 --- a/integration-tests/amazon-dynamodb/pom.xml +++ b/integration-tests/amazon-dynamodb/pom.xml @@ -37,6 +37,15 @@ quarkus-amazon-dynamodb + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + url-connection-client + + org.jboss.slf4j slf4j-jboss-logging diff --git a/integration-tests/amazon-dynamodb/src/main/resources/application.properties b/integration-tests/amazon-dynamodb/src/main/resources/application.properties index f1ee803f3215d3..0e1f4ad6a82b5b 100644 --- a/integration-tests/amazon-dynamodb/src/main/resources/application.properties +++ b/integration-tests/amazon-dynamodb/src/main/resources/application.properties @@ -1,7 +1,7 @@ quarkus.dynamodb.endpoint-override=${dynamodb.url} quarkus.dynamodb.aws.region=eu-central-1 -quarkus.dynamodb.aws.credentials.type=STATIC +quarkus.dynamodb.aws.credentials.type=static quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret