From 1e9f6bbb8c393aefa23dd905c0cdaf85a45aa8b2 Mon Sep 17 00:00:00 2001 From: Pedro Ruivo Date: Fri, 2 Aug 2024 21:24:24 +0100 Subject: [PATCH] Non clustered Keycloak with External Infinispan feature Disables JGroups (clustering) when remote-cache feature is enabled Fixes #31876 Signed-off-by: Pedro Ruivo --- .../DefaultInfinispanConnectionProviderFactory.java | 7 +++++++ .../storage/legacy/infinispan/CacheManagerFactory.java | 3 +++ 2 files changed, 10 insertions(+) diff --git a/model/infinispan/src/main/java/org/keycloak/connections/infinispan/DefaultInfinispanConnectionProviderFactory.java b/model/infinispan/src/main/java/org/keycloak/connections/infinispan/DefaultInfinispanConnectionProviderFactory.java index 46ca648925..74d1f97041 100755 --- a/model/infinispan/src/main/java/org/keycloak/connections/infinispan/DefaultInfinispanConnectionProviderFactory.java +++ b/model/infinispan/src/main/java/org/keycloak/connections/infinispan/DefaultInfinispanConnectionProviderFactory.java @@ -286,6 +286,13 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon } Marshalling.configure(gcb); + + if (InfinispanUtils.isRemoteInfinispan()) { + // Disable JGroups, not required when the data is stored in the Remote Cache. + // The existing caches are local and do not require JGroups to work properly. + gcb.nonClusteredDefault(); + } + EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build()); if (useKeycloakTimeService) { setTimeServiceToKeycloakTime(cacheManager); diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/legacy/infinispan/CacheManagerFactory.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/legacy/infinispan/CacheManagerFactory.java index 56e7036e93..f4a049c7cc 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/legacy/infinispan/CacheManagerFactory.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/legacy/infinispan/CacheManagerFactory.java @@ -347,6 +347,9 @@ public class CacheManagerFactory { logger.warnf("remote-store configuration detected for cache '%s'. Explicit cache configuration ignored when using '%s' Feature", cacheName, Profile.Feature.REMOTE_CACHE.getKey()); builders.remove(cacheName); } + // Disable JGroups, not required when the data is stored in the Remote Cache. + // The existing caches are local and do not require JGroups to work properly. + builder.getGlobalConfigurationBuilder().nonClusteredDefault(); } var start = isStartEagerly();