Search in sources :

Example 1 with StoreConfigurationBuilder

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;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) JBossUserMarshaller(org.infinispan.jboss.marshalling.core.JBossUserMarshaller)

Example 2 with StoreConfigurationBuilder

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();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder)

Example 3 with StoreConfigurationBuilder

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);
    }
}
Also used : PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 StoreConfigurationBuilder (org.infinispan.configuration.cache.StoreConfigurationBuilder)3 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 Configuration (org.infinispan.configuration.cache.Configuration)1 PersistenceConfiguration (org.infinispan.configuration.cache.PersistenceConfiguration)1 StoreConfiguration (org.infinispan.configuration.cache.StoreConfiguration)1 JBossUserMarshaller (org.infinispan.jboss.marshalling.core.JBossUserMarshaller)1 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1