From 8a163140cc3bba3ea92966539f97409be133d166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Ataxexe=20Guimar=C3=A3es?= Date: Wed, 21 Aug 2024 12:12:27 +0200 Subject: [PATCH] Add socket timeout config for the hotrod client --- .../client/deployment/InfinispanConfigurationSetupTest.java | 1 + .../src/test/resources/cache-config-application.properties | 1 + .../infinispan/client/runtime/InfinispanClientProducer.java | 4 ++++ .../client/runtime/InfinispanClientRuntimeConfig.java | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/extensions/infinispan-client/deployment/src/test/java/org/quarkus/infinispan/client/deployment/InfinispanConfigurationSetupTest.java b/extensions/infinispan-client/deployment/src/test/java/org/quarkus/infinispan/client/deployment/InfinispanConfigurationSetupTest.java index 53f90e5ad105e..b5051f83b5c94 100644 --- a/extensions/infinispan-client/deployment/src/test/java/org/quarkus/infinispan/client/deployment/InfinispanConfigurationSetupTest.java +++ b/extensions/infinispan-client/deployment/src/test/java/org/quarkus/infinispan/client/deployment/InfinispanConfigurationSetupTest.java @@ -45,6 +45,7 @@ public void infinispanConnectionConfiguration() { assertThat(configuration.security().ssl().ciphers()).containsExactlyInAnyOrder("SSL_cipher1", "SSL_cipher2"); assertThat(configuration.security().ssl().hostnameValidation()).isTrue(); assertThat(configuration.security().ssl().sniHostName()).isEqualTo("sniHostName"); + assertThat(configuration.socketTimeout()).isEqualTo(10000); assertThat(configuration.clusters()).extracting("clusterName", "clientIntelligence") .containsExactly(tuple("bsite", ClientIntelligence.BASIC)); assertThat(configuration.clusters()).hasSize(1); diff --git a/extensions/infinispan-client/deployment/src/test/resources/cache-config-application.properties b/extensions/infinispan-client/deployment/src/test/resources/cache-config-application.properties index 2c2add6b4dcea..b0e8b172ad8dd 100644 --- a/extensions/infinispan-client/deployment/src/test/resources/cache-config-application.properties +++ b/extensions/infinispan-client/deployment/src/test/resources/cache-config-application.properties @@ -18,6 +18,7 @@ quarkus.infinispan-client.ssl-protocol=SSL_protocol quarkus.infinispan-client.ssl-ciphers=SSL_cipher1,SSL_cipher2 quarkus.infinispan-client.ssl-host-name-validation=true quarkus.infinispan-client.sni-host-name=sniHostName +quarkus.infinispan-client.socket-timeout=10000 quarkus.infinispan-client.backup-cluster.bsite.hosts=bsite1:32111 quarkus.infinispan-client.backup-cluster.bsite.client-intelligence=BASIC diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientProducer.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientProducer.java index 11ba2d4c1d708..068a67d97bd64 100644 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientProducer.java +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientProducer.java @@ -273,6 +273,10 @@ private ConfigurationBuilder builderFromProperties(String infinispanClientName, properties.put(ConfigurationProperties.SNI_HOST_NAME, infinispanClientRuntimeConfig.sniHostName.get()); } + if (infinispanClientRuntimeConfig.socketTimeout.isPresent()) { + properties.put(ConfigurationProperties.SO_TIMEOUT, infinispanClientRuntimeConfig.socketTimeout.get()); + } + builder.withProperties(properties); if (infinispanClientRuntimeConfig.tracingPropagationEnabled.isPresent()) { diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientRuntimeConfig.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientRuntimeConfig.java index 0c8db06302226..0699cb40a142a 100644 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientRuntimeConfig.java +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientRuntimeConfig.java @@ -179,6 +179,12 @@ public class InfinispanClientRuntimeConfig { @ConfigItem Optional sniHostName; + /** + * Configures the socket timeout. + */ + @ConfigItem + Optional socketTimeout; + /** * Whether a tracing propagation is enabled in case the Opentelemetry extension is present. * By default the propagation of the context is propagated from the client to the Infinispan Server.