Merge pull request #4548 from hmlnarik/KEYCLOAK-5656-Transport-factory-should-not-limit-to-a-single-DC-2
KEYCLOAK-5656 Remove remoteServers configuration option
This commit is contained in:
commit
ab8f4720d6
5 changed files with 0 additions and 56 deletions
|
@ -123,7 +123,6 @@ Keycloak servers setup
|
||||||
<store class="org.keycloak.models.sessions.infinispan.remotestore.KeycloakRemoteStoreConfigurationBuilder" passivation="false" fetch-state="false" purge="false" preload="false" shared="true">
|
<store class="org.keycloak.models.sessions.infinispan.remotestore.KeycloakRemoteStoreConfigurationBuilder" passivation="false" fetch-state="false" purge="false" preload="false" shared="true">
|
||||||
<property name="rawValues">true</property>
|
<property name="rawValues">true</property>
|
||||||
<property name="marshaller">org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory</property>
|
<property name="marshaller">org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory</property>
|
||||||
<property name="remoteServers">localhost:${remote.cache.port}</property>
|
|
||||||
<property name="remoteCacheName">work</property>
|
<property name="remoteCacheName">work</property>
|
||||||
<property name="sessionCache">false</property>
|
<property name="sessionCache">false</property>
|
||||||
</store>
|
</store>
|
||||||
|
|
|
@ -355,7 +355,6 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
|
||||||
builder.persistence()
|
builder.persistence()
|
||||||
.passivation(false)
|
.passivation(false)
|
||||||
.addStore(KeycloakRemoteStoreConfigurationBuilder.class)
|
.addStore(KeycloakRemoteStoreConfigurationBuilder.class)
|
||||||
.remoteServers(jdgServer + ":" + jdgPort)
|
|
||||||
.sessionCache(sessionCache)
|
.sessionCache(sessionCache)
|
||||||
.fetchPersistentState(false)
|
.fetchPersistentState(false)
|
||||||
.ignoreModifications(false)
|
.ignoreModifications(false)
|
||||||
|
@ -384,7 +383,6 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
|
||||||
builder.persistence()
|
builder.persistence()
|
||||||
.passivation(false)
|
.passivation(false)
|
||||||
.addStore(KeycloakRemoteStoreConfigurationBuilder.class)
|
.addStore(KeycloakRemoteStoreConfigurationBuilder.class)
|
||||||
.remoteServers(jdgServer + ":" + jdgPort)
|
|
||||||
.sessionCache(false)
|
.sessionCache(false)
|
||||||
.fetchPersistentState(false)
|
.fetchPersistentState(false)
|
||||||
.ignoreModifications(false)
|
.ignoreModifications(false)
|
||||||
|
|
|
@ -31,18 +31,15 @@ import org.infinispan.persistence.remote.configuration.RemoteStoreConfiguration;
|
||||||
public class KeycloakRemoteStoreConfiguration extends RemoteStoreConfiguration {
|
public class KeycloakRemoteStoreConfiguration extends RemoteStoreConfiguration {
|
||||||
|
|
||||||
static final AttributeDefinition<String> USE_CONFIG_TEMPLATE_FROM_CACHE = AttributeDefinition.builder("useConfigTemplateFromCache", null, String.class).immutable().build();
|
static final AttributeDefinition<String> USE_CONFIG_TEMPLATE_FROM_CACHE = AttributeDefinition.builder("useConfigTemplateFromCache", null, String.class).immutable().build();
|
||||||
static final AttributeDefinition<String> REMOTE_SERVERS = AttributeDefinition.builder("remoteServers", null, String.class).immutable().build();
|
|
||||||
static final AttributeDefinition<Boolean> SESSION_CACHE = AttributeDefinition.builder("sessionCache", null, Boolean.class).immutable().build();
|
static final AttributeDefinition<Boolean> SESSION_CACHE = AttributeDefinition.builder("sessionCache", null, Boolean.class).immutable().build();
|
||||||
|
|
||||||
private final Attribute<String> useConfigTemplateFromCache;
|
private final Attribute<String> useConfigTemplateFromCache;
|
||||||
private final Attribute<String> remoteServers;
|
|
||||||
private final Attribute<Boolean> sessionCache;
|
private final Attribute<Boolean> sessionCache;
|
||||||
|
|
||||||
|
|
||||||
public KeycloakRemoteStoreConfiguration(RemoteStoreConfiguration other) {
|
public KeycloakRemoteStoreConfiguration(RemoteStoreConfiguration other) {
|
||||||
super(other.attributes(), other.async(), other.singletonStore(), other.asyncExecutorFactory(), other.connectionPool());
|
super(other.attributes(), other.async(), other.singletonStore(), other.asyncExecutorFactory(), other.connectionPool());
|
||||||
useConfigTemplateFromCache = attributes.attribute(USE_CONFIG_TEMPLATE_FROM_CACHE.name());
|
useConfigTemplateFromCache = attributes.attribute(USE_CONFIG_TEMPLATE_FROM_CACHE.name());
|
||||||
remoteServers = attributes.attribute(REMOTE_SERVERS.name());
|
|
||||||
sessionCache = attributes.attribute(SESSION_CACHE.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() {
|
public Boolean sessionCache() {
|
||||||
return sessionCache.get()==null ? false : sessionCache.get();
|
return sessionCache.get()==null ? false : sessionCache.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
package org.keycloak.models.sessions.infinispan.remotestore;
|
package org.keycloak.models.sessions.infinispan.remotestore;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.infinispan.commons.CacheConfigurationException;
|
import org.infinispan.commons.CacheConfigurationException;
|
||||||
import org.infinispan.commons.configuration.attributes.Attribute;
|
import org.infinispan.commons.configuration.attributes.Attribute;
|
||||||
|
@ -49,10 +47,6 @@ public class KeycloakRemoteStoreConfigurationBuilder extends RemoteStoreConfigur
|
||||||
Attribute<String> attribute = def.toAttribute();
|
Attribute<String> attribute = def.toAttribute();
|
||||||
attributesInternal.put(def.name(), attribute);
|
attributesInternal.put(def.name(), attribute);
|
||||||
|
|
||||||
def = KeycloakRemoteStoreConfiguration.REMOTE_SERVERS;
|
|
||||||
attribute = def.toAttribute();
|
|
||||||
attributesInternal.put(def.name(), attribute);
|
|
||||||
|
|
||||||
AttributeDefinition<Boolean> defBool = KeycloakRemoteStoreConfiguration.SESSION_CACHE;
|
AttributeDefinition<Boolean> defBool = KeycloakRemoteStoreConfiguration.SESSION_CACHE;
|
||||||
Attribute<Boolean> attributeBool = defBool.toAttribute();
|
Attribute<Boolean> attributeBool = defBool.toAttribute();
|
||||||
attributesInternal.put(defBool.name(), attributeBool);
|
attributesInternal.put(defBool.name(), attributeBool);
|
||||||
|
@ -65,12 +59,6 @@ public class KeycloakRemoteStoreConfigurationBuilder extends RemoteStoreConfigur
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KeycloakRemoteStoreConfiguration create() {
|
public KeycloakRemoteStoreConfiguration create() {
|
||||||
String remoteServersAttr = attributes.attribute(KeycloakRemoteStoreConfiguration.REMOTE_SERVERS).get();
|
|
||||||
boolean isServersAlreadySet = isServersAlreadySet();
|
|
||||||
if (remoteServersAttr != null && !isServersAlreadySet) {
|
|
||||||
parseRemoteServersAttr(remoteServersAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoteStoreConfiguration cfg = super.create();
|
RemoteStoreConfiguration cfg = super.create();
|
||||||
KeycloakRemoteStoreConfiguration cfg2 = new KeycloakRemoteStoreConfiguration(cfg);
|
KeycloakRemoteStoreConfiguration cfg2 = new KeycloakRemoteStoreConfiguration(cfg);
|
||||||
return cfg2;
|
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) {
|
public KeycloakRemoteStoreConfigurationBuilder sessionCache(Boolean sessionCache) {
|
||||||
attributes.attribute(KeycloakRemoteStoreConfiguration.SESSION_CACHE).set(sessionCache);
|
attributes.attribute(KeycloakRemoteStoreConfiguration.SESSION_CACHE).set(sessionCache);
|
||||||
return this;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ echo ** Update replicated-cache work element **
|
||||||
name=properties, value={ \
|
name=properties, value={ \
|
||||||
rawValues=true, \
|
rawValues=true, \
|
||||||
marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
|
marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
|
||||||
remoteServers=localhost:${remote.cache.port}, \
|
|
||||||
remoteCacheName=work, \
|
remoteCacheName=work, \
|
||||||
sessionCache=false \
|
sessionCache=false \
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Reference in a new issue