From fe972ce12b32c24723e92c22fbc2d437120d77d5 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Mon, 9 Oct 2017 11:54:22 +0200 Subject: [PATCH] KEYCLOAK-5656 Remove remoteServers configuration option --- misc/CrossDataCenter.md | 1 - ...ltInfinispanConnectionProviderFactory.java | 2 - .../KeycloakRemoteStoreConfiguration.java | 8 ---- ...ycloakRemoteStoreConfigurationBuilder.java | 44 ------------------- .../jboss/common/crossdc/cross-dc-setup.cli | 1 - 5 files changed, 56 deletions(-) diff --git a/misc/CrossDataCenter.md b/misc/CrossDataCenter.md index aa22128c79..21dd586654 100644 --- a/misc/CrossDataCenter.md +++ b/misc/CrossDataCenter.md @@ -123,7 +123,6 @@ Keycloak servers setup true org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory - localhost:${remote.cache.port} work false 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 0c3b820ffc..6c84385b54 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 @@ -355,7 +355,6 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon builder.persistence() .passivation(false) .addStore(KeycloakRemoteStoreConfigurationBuilder.class) - .remoteServers(jdgServer + ":" + jdgPort) .sessionCache(sessionCache) .fetchPersistentState(false) .ignoreModifications(false) @@ -384,7 +383,6 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon builder.persistence() .passivation(false) .addStore(KeycloakRemoteStoreConfigurationBuilder.class) - .remoteServers(jdgServer + ":" + jdgPort) .sessionCache(false) .fetchPersistentState(false) .ignoreModifications(false) diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfiguration.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfiguration.java index 3f7d258186..fda2c76a61 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfiguration.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfiguration.java @@ -31,18 +31,15 @@ import org.infinispan.persistence.remote.configuration.RemoteStoreConfiguration; public class KeycloakRemoteStoreConfiguration extends RemoteStoreConfiguration { static final AttributeDefinition USE_CONFIG_TEMPLATE_FROM_CACHE = AttributeDefinition.builder("useConfigTemplateFromCache", null, String.class).immutable().build(); - static final AttributeDefinition REMOTE_SERVERS = AttributeDefinition.builder("remoteServers", null, String.class).immutable().build(); static final AttributeDefinition SESSION_CACHE = AttributeDefinition.builder("sessionCache", null, Boolean.class).immutable().build(); private final Attribute useConfigTemplateFromCache; - private final Attribute remoteServers; private final Attribute sessionCache; public KeycloakRemoteStoreConfiguration(RemoteStoreConfiguration other) { super(other.attributes(), other.async(), other.singletonStore(), other.asyncExecutorFactory(), other.connectionPool()); useConfigTemplateFromCache = attributes.attribute(USE_CONFIG_TEMPLATE_FROM_CACHE.name()); - remoteServers = attributes.attribute(REMOTE_SERVERS.name()); sessionCache = attributes.attribute(SESSION_CACHE.name()); } @@ -52,11 +49,6 @@ public class KeycloakRemoteStoreConfiguration extends RemoteStoreConfiguration { } - public String remoteServers() { - return remoteServers.get(); - } - - public Boolean sessionCache() { return sessionCache.get()==null ? false : sessionCache.get(); } diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfigurationBuilder.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfigurationBuilder.java index a6ea1e6269..373411472b 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfigurationBuilder.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/KeycloakRemoteStoreConfigurationBuilder.java @@ -18,9 +18,7 @@ package org.keycloak.models.sessions.infinispan.remotestore; import java.lang.reflect.Field; -import java.util.List; import java.util.Map; -import java.util.StringTokenizer; import org.infinispan.commons.CacheConfigurationException; import org.infinispan.commons.configuration.attributes.Attribute; @@ -49,10 +47,6 @@ public class KeycloakRemoteStoreConfigurationBuilder extends RemoteStoreConfigur Attribute attribute = def.toAttribute(); attributesInternal.put(def.name(), attribute); - def = KeycloakRemoteStoreConfiguration.REMOTE_SERVERS; - attribute = def.toAttribute(); - attributesInternal.put(def.name(), attribute); - AttributeDefinition defBool = KeycloakRemoteStoreConfiguration.SESSION_CACHE; Attribute attributeBool = defBool.toAttribute(); attributesInternal.put(defBool.name(), attributeBool); @@ -65,12 +59,6 @@ public class KeycloakRemoteStoreConfigurationBuilder extends RemoteStoreConfigur @Override public KeycloakRemoteStoreConfiguration create() { - String remoteServersAttr = attributes.attribute(KeycloakRemoteStoreConfiguration.REMOTE_SERVERS).get(); - boolean isServersAlreadySet = isServersAlreadySet(); - if (remoteServersAttr != null && !isServersAlreadySet) { - parseRemoteServersAttr(remoteServersAttr); - } - RemoteStoreConfiguration cfg = super.create(); KeycloakRemoteStoreConfiguration cfg2 = new KeycloakRemoteStoreConfiguration(cfg); return cfg2; @@ -83,40 +71,8 @@ public class KeycloakRemoteStoreConfigurationBuilder extends RemoteStoreConfigur } - public KeycloakRemoteStoreConfigurationBuilder remoteServers(String remoteServers) { - attributes.attribute(KeycloakRemoteStoreConfiguration.REMOTE_SERVERS).set(remoteServers); - return this; - } - - public KeycloakRemoteStoreConfigurationBuilder sessionCache(Boolean sessionCache) { attributes.attribute(KeycloakRemoteStoreConfiguration.SESSION_CACHE).set(sessionCache); return this; } - - - private void parseRemoteServersAttr(String remoteServers) { - StringTokenizer st = new StringTokenizer(remoteServers, ","); - - while (st.hasMoreElements()) { - String nodeStr = st.nextToken(); - String[] node = nodeStr.trim().split(":", 2); - - addServer() - .host(node[0].trim()) - .port(Integer.parseInt(node[1].trim())); - } - } - - - private boolean isServersAlreadySet() { - try { - Field f = Reflections.findDeclaredField(RemoteStoreConfigurationBuilder.class, "servers"); - f.setAccessible(true); - List originalRemoteServers = (List) f.get(this); - return !originalRemoteServers.isEmpty(); - } catch (IllegalAccessException iae) { - throw new RuntimeException(iae); - } - } } diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/common/crossdc/cross-dc-setup.cli b/testsuite/integration-arquillian/servers/auth-server/jboss/common/crossdc/cross-dc-setup.cli index 6ad1234b4a..3a0a7b0cd5 100644 --- a/testsuite/integration-arquillian/servers/auth-server/jboss/common/crossdc/cross-dc-setup.cli +++ b/testsuite/integration-arquillian/servers/auth-server/jboss/common/crossdc/cross-dc-setup.cli @@ -22,7 +22,6 @@ echo ** Update replicated-cache work element ** name=properties, value={ \ rawValues=true, \ marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \ - remoteServers=localhost:${remote.cache.port}, \ remoteCacheName=work, \ sessionCache=false \ } \