parent
143e6bc932
commit
8ed9ce29d1
1 changed files with 26 additions and 10 deletions
|
@ -21,6 +21,8 @@ import org.infinispan.client.hotrod.RemoteCacheManager;
|
|||
import org.infinispan.client.hotrod.RemoteCacheManagerAdmin;
|
||||
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
|
||||
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
|
||||
import org.infinispan.client.hotrod.configuration.NearCacheMode;
|
||||
import org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder;
|
||||
import org.infinispan.commons.marshall.ProtoStreamMarshaller;
|
||||
import org.infinispan.protostream.GeneratedSchema;
|
||||
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants;
|
||||
|
@ -36,6 +38,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.keycloak.models.map.storage.hotRod.common.AutogeneratedHotRodDescriptors.ENTITY_DESCRIPTOR_MAP;
|
||||
|
@ -70,7 +73,9 @@ public class DefaultHotRodConnectionProviderFactory implements HotRodConnectionP
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
if (remoteCacheManager != null) {
|
||||
remoteCacheManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,10 +109,7 @@ public class DefaultHotRodConnectionProviderFactory implements HotRodConnectionP
|
|||
.realm(config.get("realm", "default"));
|
||||
}
|
||||
|
||||
boolean configureRemoteCaches = config.getBoolean("configureRemoteCaches", false);
|
||||
if (configureRemoteCaches) {
|
||||
configureRemoteCaches(remoteBuilder);
|
||||
}
|
||||
configureRemoteCaches(remoteBuilder);
|
||||
|
||||
remoteBuilder.addContextInitializer(CommonPrimitivesProtoSchemaInitializer.INSTANCE);
|
||||
ENTITY_DESCRIPTOR_MAP.values().stream().map(HotRodEntityDescriptor::getProtoSchema).forEach(remoteBuilder::addContextInitializer);
|
||||
|
@ -116,10 +118,8 @@ public class DefaultHotRodConnectionProviderFactory implements HotRodConnectionP
|
|||
Set<String> remoteCaches = ENTITY_DESCRIPTOR_MAP.values().stream()
|
||||
.map(HotRodEntityDescriptor::getCacheName).collect(Collectors.toSet());
|
||||
|
||||
if (configureRemoteCaches) {
|
||||
// access the caches to force their creation
|
||||
remoteCaches.forEach(remoteCacheManager::getCache);
|
||||
}
|
||||
// access the caches to force their creation
|
||||
remoteCaches.forEach(remoteCacheManager::getCache);
|
||||
|
||||
registerSchemata();
|
||||
|
||||
|
@ -209,8 +209,24 @@ public class DefaultHotRodConnectionProviderFactory implements HotRodConnectionP
|
|||
throw new RuntimeException("Cannot read the cache configuration!", e);
|
||||
}
|
||||
|
||||
Consumer<String> configurator = configurationBuilderConsumer(builder, uri);
|
||||
|
||||
ENTITY_DESCRIPTOR_MAP.values().stream()
|
||||
.map(HotRodEntityDescriptor::getCacheName)
|
||||
.forEach(name -> builder.remoteCache(name).configurationURI(uri));
|
||||
.forEach(configurator);
|
||||
}
|
||||
|
||||
private Consumer<String> configurationBuilderConsumer(ConfigurationBuilder builder, URI uri) {
|
||||
return cacheName -> {
|
||||
RemoteCacheConfigurationBuilder rb = builder.remoteCache(cacheName);
|
||||
boolean configureRemoteCaches = config.getBoolean("configureRemoteCaches", false);
|
||||
if (configureRemoteCaches) {
|
||||
rb.configurationURI(uri);
|
||||
}
|
||||
rb.nearCacheMode(config.scope(cacheName).getBoolean("nearCacheEnabled", config.getBoolean("nearCacheEnabled", true)) ? NearCacheMode.INVALIDATED : NearCacheMode.DISABLED)
|
||||
.nearCacheMaxEntries(config.scope(cacheName).getInt("nearCacheMaxEntries", config.getInt("nearCacheMaxEntries", 10000)))
|
||||
.nearCacheUseBloomFilter(config.scope(cacheName).getBoolean("nearCacheBloomFilter", config.getBoolean("nearCacheBloomFilter", false)));
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue