Make KeycloakServer runnable with external Infinispan server

Closes #12011
Closes #12014
This commit is contained in:
Michal Hajas 2022-05-16 15:21:37 +02:00 committed by Hynek Mlnařík
parent b5a5d68dbc
commit b86f205cda
3 changed files with 18 additions and 14 deletions

View file

@ -118,20 +118,19 @@ public class DefaultHotRodConnectionProviderFactory implements HotRodConnectionP
registerSchemata(ProtoSchemaInitializer.INSTANCE); registerSchemata(ProtoSchemaInitializer.INSTANCE);
String reindexCaches = config.get("reindexCaches", null);
RemoteCacheManagerAdmin administration = remoteCacheManager.administration(); RemoteCacheManagerAdmin administration = remoteCacheManager.administration();
if (config.getBoolean("reindexAllCaches", false)) { if (reindexCaches != null && reindexCaches.equals("all")) {
LOG.infof("Reindexing all caches. This can take a long time to complete. While the rebuild operation is in progress, queries might return fewer results."); LOG.infof("Reindexing all caches. This can take a long time to complete. While the rebuild operation is in progress, queries might return fewer results.");
remoteCaches.forEach(administration::reindexCache); remoteCaches.forEach(administration::reindexCache);
} else { } else if (reindexCaches != null && !reindexCaches.isEmpty()){
String reindexCaches = config.get("reindexCaches", ""); Arrays.stream(reindexCaches.split(","))
if (reindexCaches != null) { .map(String::trim)
Arrays.stream(reindexCaches.split(",")) .filter(e -> !e.isEmpty())
.map(String::trim) .filter(remoteCaches::contains)
.filter(e -> !e.isEmpty()) .peek(cacheName -> LOG.infof("Reindexing %s cache. This can take a long time to complete. While the rebuild operation is in progress, queries might return fewer results.", cacheName))
.filter(remoteCaches::contains) .forEach(administration::reindexCache);
.peek(cacheName -> LOG.infof("Reindexing %s cache. This can take a long time to complete. While the rebuild operation is in progress, queries might return fewer results.", cacheName))
.forEach(administration::reindexCache);
}
} }
} }

View file

@ -264,7 +264,7 @@
"username": "${keycloak.connectionsHotRod.username:myuser}", "username": "${keycloak.connectionsHotRod.username:myuser}",
"password": "${keycloak.connectionsHotRod.password:qwer1234!}", "password": "${keycloak.connectionsHotRod.password:qwer1234!}",
"enableSecurity": "${keycloak.connectionsHotRod.enableSecurity:true}", "enableSecurity": "${keycloak.connectionsHotRod.enableSecurity:true}",
"reindexCaches": "${keycloak.connectionsHotRod.reindexCaches:auth-sessions,clients,client-scopes,groups,users,user-login-failures,user-sessions,client-sessions,roles,realms,authz}" "reindexCaches": "${keycloak.connectionsHotRod.reindexCaches:all}"
} }
}, },

View file

@ -231,10 +231,15 @@
"default": { "default": {
"embedded": "${keycloak.connectionsHotRod.embedded:true}", "embedded": "${keycloak.connectionsHotRod.embedded:true}",
"embeddedPort": "${keycloak.connectionsHotRod.embeddedPort:11444}", "embeddedPort": "${keycloak.connectionsHotRod.embeddedPort:11444}",
"enableSecurity": "${keycloak.connectionsHotRod.enableSecurity:false}" "enableSecurity": "${keycloak.connectionsHotRod.enableSecurity:false}",
"port": "${keycloak.connectionsHotRod.port:11444}",
"host": "${keycloak.connectionsHotRod.host:localhost}",
"configureRemoteCaches": "${keycloak.connectionsHotRod.configureRemoteCaches:false}",
"username": "${keycloak.connectionsHotRod.username:admin}",
"password": "${keycloak.connectionsHotRod.password:admin}",
"reindexCaches": "${keycloak.connectionsHotRod.reindexCaches:}"
} }
}, },
"scripting": { "scripting": {
}, },