From 959728f6e3025bef7e812751b3ff10f5f6102d5f Mon Sep 17 00:00:00 2001 From: amontenegro Date: Tue, 24 Oct 2023 15:28:42 -0600 Subject: [PATCH] add an option to configure timeout --- .../main/resources/orcid-oauth2-api-common-config.xml | 1 + .../org/orcid/core/utils/cache/redis/RedisClient.java | 9 +++------ orcid-core/src/main/resources/orcid-core-context.xml | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/orcid-api-common/src/main/resources/orcid-oauth2-api-common-config.xml b/orcid-api-common/src/main/resources/orcid-oauth2-api-common-config.xml index a97fca78480..89682ff1873 100644 --- a/orcid-api-common/src/main/resources/orcid-oauth2-api-common-config.xml +++ b/orcid-api-common/src/main/resources/orcid-oauth2-api-common-config.xml @@ -131,5 +131,6 @@ + \ No newline at end of file diff --git a/orcid-core/src/main/java/org/orcid/core/utils/cache/redis/RedisClient.java b/orcid-core/src/main/java/org/orcid/core/utils/cache/redis/RedisClient.java index 42affcf8f47..bc09b7f234d 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/cache/redis/RedisClient.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/cache/redis/RedisClient.java @@ -11,6 +11,7 @@ import org.orcid.utils.alerting.SlackManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import redis.clients.jedis.DefaultJedisClientConfig; import redis.clients.jedis.HostAndPort; @@ -24,7 +25,7 @@ public class RedisClient { private static final Logger LOG = LoggerFactory.getLogger(RedisClient.class); private static final int DEFAULT_CACHE_EXPIRY = 60; - private static final int DEFAULT_TIMEOUT = 5000; + private static final int DEFAULT_TIMEOUT = 10000; private final String redisHost; private final int redisPort; @@ -37,7 +38,7 @@ public class RedisClient { @Resource private SlackManager slackManager; - // Assume the connection to Redis is disabled by default + // Assume the connection to Redis is disabled by default private boolean enabled = false; public RedisClient(String redisHost, int redisPort, String password) { @@ -66,10 +67,6 @@ public RedisClient(String redisHost, int redisPort, String password, int cacheEx @PostConstruct private void init() { - if(!enabled) { - LOG.debug("Redis is not enabled, so, it will not be initilized"); - return; - } try { JedisClientConfig config = DefaultJedisClientConfig.builder().connectionTimeoutMillis(this.clientTimeoutInMillis).timeoutMillis(this.clientTimeoutInMillis) .socketTimeoutMillis(this.clientTimeoutInMillis).password(this.redisPassword).ssl(true).build(); diff --git a/orcid-core/src/main/resources/orcid-core-context.xml b/orcid-core/src/main/resources/orcid-core-context.xml index 76f109dc3ca..94f24f912bd 100644 --- a/orcid-core/src/main/resources/orcid-core-context.xml +++ b/orcid-core/src/main/resources/orcid-core-context.xml @@ -1212,6 +1212,7 @@ +