diff --git a/distribution/server-x/assembly.xml b/distribution/server-x/assembly.xml
index d352d885db..2c47edc2b0 100755
--- a/distribution/server-x/assembly.xml
+++ b/distribution/server-x/assembly.xml
@@ -97,14 +97,12 @@
true
-
+
conf
- clustered-cache.xml
-
+
conf
- local-cache.xml
diff --git a/quarkus/deployment/pom.xml b/quarkus/deployment/pom.xml
index d9aade1826..a1fb0321b2 100644
--- a/quarkus/deployment/pom.xml
+++ b/quarkus/deployment/pom.xml
@@ -96,9 +96,6 @@
maven-surefire-plugin
-
- true
-
diff --git a/quarkus/deployment/src/test/resources/keycloak.properties b/quarkus/deployment/src/test/resources/keycloak.properties
index 6f735c3d3c..8b5f454a77 100644
--- a/quarkus/deployment/src/test/resources/keycloak.properties
+++ b/quarkus/deployment/src/test/resources/keycloak.properties
@@ -1,4 +1,5 @@
http.enabled=true
+cluster=local
db=h2-mem
db.username = sa
db.password = keycloak
\ No newline at end of file
diff --git a/quarkus/runtime/src/main/java/org/keycloak/configuration/PropertyMappers.java b/quarkus/runtime/src/main/java/org/keycloak/configuration/PropertyMappers.java
index f986592f13..738830bd23 100644
--- a/quarkus/runtime/src/main/java/org/keycloak/configuration/PropertyMappers.java
+++ b/quarkus/runtime/src/main/java/org/keycloak/configuration/PropertyMappers.java
@@ -161,16 +161,18 @@ public final class PropertyMappers {
}
private static void configureClustering() {
- createWithDefault("clustered", "kc.spi.connections-infinispan.default.clustered", "placeholder", (value, context) -> {
- if ("true".equals(value) || "false".equals(value)) {
- return value;
+ createWithDefault("cluster", "kc.spi.connections-infinispan.default.config-file", "placeholder", (value, context) -> {
+
+ if ("placeholder".equals(value)) {
+ // Clustering is disabled by default for the "dev" profile. Otherwise enabled
+ value = ("dev".equalsIgnoreCase(ProfileManager.getActiveProfile())) ? "local" : "default";
}
- // Clustering is disabled by default for the "dev" profile. Otherwise enabled
- value = ("dev".equalsIgnoreCase(ProfileManager.getActiveProfile())) ? "false" : "true";
- return value;
+ return "cluster-" + value + ".xml";
- }, "Enables Clustering. Possible values are 'true' or 'false'.");
+ }, "Specifies clustering configuration. The specified value points to the infinispan configuration file prefixed with the 'cluster-` "
+ + "inside the distribution configuration directory. Supported values out of the box are 'local' and 'cluster'. Value 'local' points to the file cluster-local.xml and " +
+ "effectively disables clustering and use infinispan caches in the local mode. Value 'default' points to the file cluster-default.xml, which has clustering enabled for infinispan caches.");
}
static ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
diff --git a/quarkus/runtime/src/main/java/org/keycloak/provider/quarkus/QuarkusCacheManagerProvider.java b/quarkus/runtime/src/main/java/org/keycloak/provider/quarkus/QuarkusCacheManagerProvider.java
index ee09c260b6..12b41d3d25 100644
--- a/quarkus/runtime/src/main/java/org/keycloak/provider/quarkus/QuarkusCacheManagerProvider.java
+++ b/quarkus/runtime/src/main/java/org/keycloak/provider/quarkus/QuarkusCacheManagerProvider.java
@@ -40,11 +40,7 @@ import org.keycloak.util.Environment;
*/
public final class QuarkusCacheManagerProvider implements ManagedCacheManagerProvider {
- private static final Logger log = Logger.getLogger(QuarkusCacheManagerProvider.class);
-
- // Configuration files from the distribution
- private static final String DEFAULT_CLUSTER_CONFIGURATION_FILE = "clustered-cache.xml";
- private static final String DEFAULT_LOCAL_CONFIGURATION_FILE = "local-cache.xml";
+ private static final Logger log = Logger.getLogger(QuarkusCacheManagerProvider.class);
@Override
public C getCacheManager(Config.Scope config) {
@@ -68,15 +64,16 @@ public final class QuarkusCacheManagerProvider implements ManagedCacheManagerPro
}
private InputStream loadConfiguration(Config.Scope config) throws FileNotFoundException {
+ String pathPrefix;
String homeDir = Environment.getHomeDir();
if (homeDir == null) {
log.warn("Keycloak home directory not set.");
- return loadDefaultConfiguration(config, "default-clustered-cache.xml", "default-local-cache.xml");
+ pathPrefix = "";
+ } else {
+ pathPrefix = homeDir + "/conf/";
}
- String pathPrefix = homeDir + "/conf/";
-
// Always try to use "configFile" if explicitly specified
String configFile = config.get("configFile");
if (configFile != null) {
@@ -87,24 +84,13 @@ public final class QuarkusCacheManagerProvider implements ManagedCacheManagerPro
return FileLookupFactory.newInstance()
.lookupFileStrict(configPath.toUri(), Thread.currentThread().getContextClassLoader());
} else {
- log.warnf("Cache configuration file does not exists at %s . Fallback to the default configuration file", configPath);
+ log.infof("Loading cache configuration from %s", configPath);
+ return FileLookupFactory.newInstance()
+ .lookupFileStrict(configPath.getFileName().toString(), Thread.currentThread().getContextClassLoader());
}
+ } else {
+ throw new IllegalStateException("Option 'configFile' needs to be specified");
}
-
- return loadDefaultConfiguration(config, pathPrefix + DEFAULT_CLUSTER_CONFIGURATION_FILE, pathPrefix + DEFAULT_LOCAL_CONFIGURATION_FILE);
- }
-
- private InputStream loadDefaultConfiguration(Config.Scope config, String defaultClusterConfigFile, String defaultLocalConfigFile) throws FileNotFoundException {
- if (config.getBoolean("clustered", false)) {
- log.infof("Using default clustered cache configuration from file %s", defaultClusterConfigFile);
- return FileLookupFactory.newInstance()
- .lookupFileStrict(defaultClusterConfigFile, Thread.currentThread().getContextClassLoader());
- }
-
- log.infof("Using default local cache configuration from file %s", defaultLocalConfigFile);
-
- return FileLookupFactory.newInstance()
- .lookupFileStrict(defaultLocalConfigFile, Thread.currentThread().getContextClassLoader());
}
private void configureTransportStack(Config.Scope config, ConfigurationBuilderHolder builder) {
diff --git a/quarkus/runtime/src/main/resources/default-clustered-cache.xml b/quarkus/runtime/src/main/resources/cluster-default.xml
similarity index 100%
rename from quarkus/runtime/src/main/resources/default-clustered-cache.xml
rename to quarkus/runtime/src/main/resources/cluster-default.xml
diff --git a/quarkus/runtime/src/main/resources/default-local-cache.xml b/quarkus/runtime/src/main/resources/cluster-local.xml
similarity index 100%
rename from quarkus/runtime/src/main/resources/default-local-cache.xml
rename to quarkus/runtime/src/main/resources/cluster-local.xml
diff --git a/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java b/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java
index 3b6112de10..dfe7018b75 100644
--- a/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java
+++ b/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java
@@ -233,18 +233,17 @@ public class ConfigurationTest {
@Test
public void testClusterConfig() {
// Cluster enabled by default, but disabled for the "dev" profile
- Assert.assertTrue(initConfig("connectionsInfinispan", "default").getBoolean("clustered"));
+ Assert.assertEquals("cluster-default.xml", initConfig("connectionsInfinispan", "default").get("configFile"));
System.setProperty("kc.profile", "dev");
- Assert.assertFalse(initConfig("connectionsInfinispan", "default").getBoolean("clustered"));
+ Assert.assertEquals("cluster-local.xml", initConfig("connectionsInfinispan", "default").get("configFile"));
// If explicitly set, then it is always used regardless of the profile
System.clearProperty("kc.profile");
- System.setProperty("kc.config.args", "--clustered=true");
+ System.setProperty("kc.config.args", "--cluster=foo");
- Assert.assertTrue(initConfig("connectionsInfinispan", "default").getBoolean("clustered"));
+ Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "default").get("configFile"));
System.setProperty("kc.profile", "dev");
- Assert.assertTrue(initConfig("connectionsInfinispan", "default").getBoolean("clustered"));
-
+ Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "default").get("configFile"));
}
private Config.Scope initConfig(String... scope) {