Search in sources :

Example 31 with Configuration

use of org.infinispan.configuration.cache.Configuration in project OpenOLAT by OpenOLAT.

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 32 with Configuration

use of org.infinispan.configuration.cache.Configuration 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 33 with Configuration

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

the class CacheEntryMutatorTestCase method mutateNonTransactional.

@Test
public void mutateNonTransactional() {
    AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
    Object id = new Object();
    Object value = new Object();
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    when(cache.getCacheConfiguration()).thenReturn(config);
    Mutator mutator = new CacheEntryMutator<>(cache, id, value);
    when(cache.getAdvancedCache()).thenReturn(cache);
    when(cache.withFlags(Flag.IGNORE_RETURN_VALUES, Flag.FAIL_SILENTLY)).thenReturn(cache);
    mutator.mutate();
    verify(cache).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(2)).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(3)).put(same(id), same(value));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Mutator(org.wildfly.clustering.ee.Mutator) Test(org.junit.Test)

Example 34 with Configuration

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

the class InfinispanCachePropertiesTestCase method isTransactional.

@Test
public void isTransactional() {
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isTransactional());
    config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    Assert.assertFalse(new InfinispanCacheProperties(config).isTransactional());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Example 35 with Configuration

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

the class InfinispanCachePropertiesTestCase method isLockOnRead.

@Test
public void isLockOnRead() {
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC).locking().isolationLevel(IsolationLevel.REPEATABLE_READ).build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isLockOnRead());
    Configuration optimistic = config = new ConfigurationBuilder().read(config).transaction().lockingMode(LockingMode.OPTIMISTIC).build();
    Assert.assertFalse(new InfinispanCacheProperties(optimistic).isLockOnRead());
    Configuration nonTx = new ConfigurationBuilder().read(config).transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    Assert.assertFalse(new InfinispanCacheProperties(nonTx).isLockOnRead());
    Configuration readCommitted = config = new ConfigurationBuilder().read(config).locking().isolationLevel(IsolationLevel.READ_COMMITTED).build();
    Assert.assertFalse(new InfinispanCacheProperties(readCommitted).isLockOnRead());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Aggregations

Configuration (org.infinispan.configuration.cache.Configuration)37 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)24 Test (org.junit.Test)24 Properties (java.util.Properties)12 AdvancedCache (org.infinispan.AdvancedCache)9 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)6 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)5 EntityRegionImpl (org.hibernate.cache.infinispan.entity.EntityRegionImpl)4 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)4 CacheMode (org.infinispan.configuration.cache.CacheMode)3 TransactionConfiguration (org.infinispan.configuration.cache.TransactionConfiguration)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 CollectionRegionImpl (org.hibernate.cache.infinispan.collection.CollectionRegionImpl)2 QueryResultsRegionImpl (org.hibernate.cache.infinispan.query.QueryResultsRegionImpl)2 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)2 CacheProperties (org.wildfly.clustering.ee.cache.CacheProperties)2 TransactionBatch (org.wildfly.clustering.ee.infinispan.TransactionBatch)2 Method (java.lang.reflect.Method)1 Map (java.util.Map)1