use of org.infinispan.configuration.cache.StoreConfigurationBuilder in project keycloak by keycloak.
the class TestCacheManagerFactory method createManager.
<T extends StoreConfigurationBuilder<?, T> & RemoteStoreConfigurationChildBuilder<T>> EmbeddedCacheManager createManager(int threadId, String cacheName, Class<T> builderClass) {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("jgroups.tcp.port", "53715");
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb = gcb.clusteredDefault();
gcb.transport().clusterName("test-clustering-" + threadId);
// For Infinispan 10, we go with the JBoss marshalling.
// TODO: This should be replaced later with the marshalling recommended by infinispan. Probably protostream.
// See https://infinispan.org/docs/stable/titles/developing/developing.html#marshalling for the details
gcb.serialization().marshaller(new JBossUserMarshaller());
gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN + "-" + threadId).enable();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
Configuration invalidationCacheConfiguration = getCacheBackedByRemoteStore(threadId, cacheName, builderClass);
cacheManager.defineConfiguration(cacheName, invalidationCacheConfiguration);
cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
return cacheManager;
}
use of org.infinispan.configuration.cache.StoreConfigurationBuilder in project keycloak by keycloak.
the class TestCacheManagerFactory method getCacheBackedByRemoteStore.
private <T extends StoreConfigurationBuilder<?, T> & RemoteStoreConfigurationChildBuilder<T>> Configuration getCacheBackedByRemoteStore(int threadId, String cacheName, Class<T> builderClass) {
ConfigurationBuilder cacheConfigBuilder = new ConfigurationBuilder();
String host = threadId == 1 ? "jdg1" : "jdg2";
int port = 11222;
return cacheConfigBuilder.statistics().enable().persistence().addStore(builderClass).fetchPersistentState(false).ignoreModifications(false).purgeOnStartup(false).preload(false).shared(true).remoteCacheName(cacheName).rawValues(true).forceReturnValues(false).marshaller(KeycloakHotRodMarshallerFactory.class.getName()).protocolVersion(ProtocolVersion.PROTOCOL_VERSION_29).addServer().host(host).port(port).connectionPool().maxActive(20).exhaustedAction(ExhaustedAction.CREATE_NEW).async().enabled(false).build();
}
use of org.infinispan.configuration.cache.StoreConfigurationBuilder in project wildfly by wildfly.
the class CustomStoreServiceConfigurator method get.
@Override
public PersistenceConfiguration get() {
PersistenceConfiguration persistence = super.get();
StoreConfiguration store = persistence.stores().get(0);
try {
@SuppressWarnings("unchecked") Class<StoreConfigurationBuilder<?, ?>> storeClass = (Class<StoreConfigurationBuilder<?, ?>>) this.module.get().getClassLoader().loadClass(this.className).asSubclass(StoreConfigurationBuilder.class);
return new ConfigurationBuilder().persistence().passivation(persistence.passivation()).addStore(storeClass).async().read(store.async()).fetchPersistentState(store.fetchPersistentState()).preload(store.preload()).purgeOnStartup(store.purgeOnStartup()).shared(store.shared()).withProperties(store.properties()).persistence().create();
} catch (ClassNotFoundException | ClassCastException e) {
throw InfinispanLogger.ROOT_LOGGER.invalidCacheStore(e, this.className);
}
}
Aggregations