Search in sources :

Example 61 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class MemoryServiceConfigurator method get.

@Override
public MemoryConfiguration get() {
    EvictionStrategy strategy = this.size > 0 ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL;
    MemoryConfigurationBuilder builder = new ConfigurationBuilder().memory().storage(this.storageType).whenFull(strategy);
    if (strategy.isEnabled()) {
        if (this.unit == MemorySizeUnit.ENTRIES) {
            builder.maxCount(this.size);
        } else {
            builder.maxSize(Long.toString(this.unit.applyAsLong(this.size)));
        }
    }
    return builder.create();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) MemoryConfigurationBuilder(org.infinispan.configuration.cache.MemoryConfigurationBuilder) MemoryConfigurationBuilder(org.infinispan.configuration.cache.MemoryConfigurationBuilder) EvictionStrategy(org.infinispan.eviction.EvictionStrategy)

Example 62 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project openolat by klemens.

the class InfinispanCacher method createInfinispanConfiguration.

private void createInfinispanConfiguration(String cacheName) {
    Configuration conf = cacheManager.getCacheConfiguration(cacheName);
    if (conf == null) {
        long maxEntries = 10000;
        long maxIdle = 900000l;
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.eviction().strategy(EvictionStrategy.LRU);
        builder.eviction().type(EvictionType.COUNT).size(maxEntries);
        builder.expiration().maxIdle(maxIdle);
        builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
        builder.dataContainer().storeAsBinary().storeValuesAsBinary(false);
        builder.locking().concurrencyLevel(1000);
        builder.locking().useLockStriping(false);
        builder.locking().lockAcquisitionTimeout(15000);
        builder.locking().isolationLevel(IsolationLevel.READ_COMMITTED);
        builder.jmxStatistics().enable();
        Configuration configurationOverride = builder.build();
        cacheManager.defineConfiguration(cacheName, configurationOverride);
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration)

Example 63 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.

the class ClusteredCacheBehaviorTest method createManager.

public EmbeddedCacheManager createManager() {
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("jgroups.tcp.port", "53715");
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb = gcb.clusteredDefault();
    gcb.transport().clusterName("test-clustering");
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
    invalidationConfigBuilder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
    Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
    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) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 64 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.

the class ConcurrencyLockingTest method getVersionedCacheManager.

protected DefaultCacheManager getVersionedCacheManager() {
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    final DefaultCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
    Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
    ConfigurationBuilder counterConfigBuilder = new ConfigurationBuilder();
    counterConfigBuilder.invocationBatching().enable();
    counterConfigBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup());
    counterConfigBuilder.transaction().lockingMode(LockingMode.PESSIMISTIC);
    Configuration counterCacheConfiguration = counterConfigBuilder.build();
    cacheManager.defineConfiguration("COUNTER_CACHE", counterCacheConfiguration);
    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) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)

Example 65 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.

the class DistributedCacheConcurrentWritesTest method createManager.

public static EmbeddedCacheManager createManager(String nodeName) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("jgroups.tcp.port", "53715");
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb = gcb.clusteredDefault();
    gcb.transport().clusterName("test-clustering");
    gcb.transport().nodeName(nodeName);
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder distConfigBuilder = new ConfigurationBuilder();
    distConfigBuilder.clustering().cacheMode(CacheMode.DIST_SYNC);
    distConfigBuilder.clustering().hash().numOwners(1);
    // Disable L1 cache
    distConfigBuilder.clustering().hash().l1().enabled(false);
    Configuration distConfig = distConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME, distConfig);
    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) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)71 Configuration (org.infinispan.configuration.cache.Configuration)36 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)29 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)23 Test (org.junit.Test)19 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)9 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)8 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)7 Properties (java.util.Properties)6 Map (java.util.Map)5 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)5 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)5 BeforeClass (org.junit.BeforeClass)5 AdvancedCache (org.infinispan.AdvancedCache)4 BackupConfiguration (org.infinispan.configuration.cache.BackupConfiguration)3 BackupConfigurationBuilder (org.infinispan.configuration.cache.BackupConfigurationBuilder)3 CacheMode (org.infinispan.configuration.cache.CacheMode)3 SitesConfigurationBuilder (org.infinispan.configuration.cache.SitesConfigurationBuilder)3 TransportConfigurationBuilder (org.infinispan.configuration.global.TransportConfigurationBuilder)3 EmbeddedTransactionManagerLookup (org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)3