From db9b6c2152a7b05bb5d57c1fcab9b1d2fb8515f1 Mon Sep 17 00:00:00 2001 From: Martin Kanis Date: Fri, 16 Jun 2023 15:51:26 +0200 Subject: [PATCH] Make awaitInitialTransfer for ISPN configurable Closes #16671 --- ...ultInfinispanConnectionProviderFactory.java | 3 ++- .../testsuite/model/parameters/Infinispan.java | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) 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 ce77dd0442..b9f543aff0 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 @@ -253,6 +253,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon int l1Lifespan = config.getInt("l1Lifespan", 600000); boolean l1Enabled = l1Lifespan > 0; + Boolean awaitInitialTransfer = config.getBoolean("awaitInitialTransfer", true); sessionConfigBuilder.clustering() .hash() .numOwners(owners) @@ -260,7 +261,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon .l1() .enabled(l1Enabled) .lifespan(l1Lifespan) - .stateTransfer().timeout(30, TimeUnit.SECONDS) + .stateTransfer().awaitInitialTransfer(awaitInitialTransfer).timeout(30, TimeUnit.SECONDS) .build(); } diff --git a/testsuite/model/src/test/java/org/keycloak/testsuite/model/parameters/Infinispan.java b/testsuite/model/src/test/java/org/keycloak/testsuite/model/parameters/Infinispan.java index ebdd303db2..82bb18720e 100644 --- a/testsuite/model/src/test/java/org/keycloak/testsuite/model/parameters/Infinispan.java +++ b/testsuite/model/src/test/java/org/keycloak/testsuite/model/parameters/Infinispan.java @@ -95,13 +95,17 @@ public class Infinispan extends KeycloakModelParameters { @Override public void updateConfig(Config cf) { - cf.spi("connectionsInfinispan") - .provider("default") - .config("embedded", "true") - .config("clustered", "true") - .config("useKeycloakTimeService", "true") - .config("nodeName", "node-" + NODE_COUNTER.incrementAndGet()) - .spi(UserLoginFailureSpi.NAME) + Config.ProviderConfig provider = cf.spi("connectionsInfinispan").provider("default"); + provider = provider.config("embedded", "true") + .config("clustered", "true") + .config("useKeycloakTimeService", "true") + .config("nodeName", "node-" + NODE_COUNTER.incrementAndGet()); + + String preloading = System.getProperty("keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase"); + if (preloading != null && "true".equals(preloading)) { + provider.config("awaitInitialTransfer", "false"); + } + cf.spi(UserLoginFailureSpi.NAME) .provider(InfinispanUserLoginFailureProviderFactory.PROVIDER_ID) .config("stalledTimeoutInSeconds", "10") .spi(UserSessionSpi.NAME)