use of org.keycloak.models.map.storage.hotRod.common.HotRodEntityDescriptor in project keycloak by keycloak.
the class DefaultHotRodConnectionProviderFactory method lazyInit.
public void lazyInit() {
if (config.getBoolean("embedded", false)) {
HotRodUtils.createHotRodMapStoreServer(config.getInt("embeddedPort", 11444));
}
ConfigurationBuilder remoteBuilder = new ConfigurationBuilder();
remoteBuilder.addServer().host(config.get("host", "localhost")).port(config.getInt("port", 11444)).clientIntelligence(ClientIntelligence.HASH_DISTRIBUTION_AWARE).marshaller(new ProtoStreamMarshaller());
if (config.getBoolean("enableSecurity", true)) {
remoteBuilder.security().authentication().saslMechanism("SCRAM-SHA-512").username(config.get("username", "admin")).password(config.get("password", "admin")).realm(config.get("realm", "default"));
}
boolean configureRemoteCaches = config.getBoolean("configureRemoteCaches", false);
if (configureRemoteCaches) {
configureRemoteCaches(remoteBuilder);
}
remoteBuilder.addContextInitializer(ProtoSchemaInitializer.INSTANCE);
remoteCacheManager = new RemoteCacheManager(remoteBuilder.build());
Set<String> remoteCaches = HotRodMapStorageProviderFactory.ENTITY_DESCRIPTOR_MAP.values().stream().map(HotRodEntityDescriptor::getCacheName).collect(Collectors.toSet());
if (configureRemoteCaches) {
// access the caches to force their creation
remoteCaches.forEach(remoteCacheManager::getCache);
}
registerSchemata(ProtoSchemaInitializer.INSTANCE);
RemoteCacheManagerAdmin administration = remoteCacheManager.administration();
if (config.getBoolean("reindexAllCaches", false)) {
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);
} else {
String reindexCaches = config.get("reindexCaches", "");
if (reindexCaches != null) {
Arrays.stream(reindexCaches.split(",")).map(String::trim).filter(e -> !e.isEmpty()).filter(remoteCaches::contains).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);
}
}
}
Aggregations