Search in sources :

Example 51 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project indy by Commonjava.

the class MetadataCacheManagerTest method setup.

@Before
public void setup() throws Exception {
    DefaultCacheManager cacheManager = new DefaultCacheManager(new ConfigurationBuilder().simpleCache(true).build());
    cacheProducer = new CacheProducer(null, cacheManager, null);
    CacheHandle<MetadataKey, MetadataKey> metadataKeyCache = cacheProducer.getCache("maven-metadata-key-cache");
    CacheHandle<MetadataKey, MetadataInfo> metadataCache = cacheProducer.getCache("maven-metadata-cache");
    metadataCacheManager = new MetadataCacheManager(metadataCache, metadataKeyCache);
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheProducer(org.commonjava.indy.subsys.infinispan.CacheProducer) Before(org.junit.Before)

Example 52 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project indy by Commonjava.

the class InfinispanTCKFixtureProvider method init.

protected void init() {
    DefaultCacheManager cacheManager = new DefaultCacheManager(new ConfigurationBuilder().simpleCache(true).build());
    Cache<StoreKey, ArtifactStore> storeCache = cacheManager.getCache(STORE_DATA_CACHE, true);
    Cache<String, Map<StoreType, Set<StoreKey>>> storesByPkgCache = cacheManager.getCache(STORE_BY_PKG_CACHE, true);
    Cache<StoreKey, Set<StoreKey>> affected = cacheManager.getCache(AFFECTED_BY_STORE_CACHE, true);
    dataManager = new InfinispanStoreDataManager(storeCache, storesByPkgCache, affected);
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Set(java.util.Set) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) StoreKey(org.commonjava.indy.model.core.StoreKey) Map(java.util.Map)

Example 53 with ConfigurationBuilder

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

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

use of org.infinispan.configuration.cache.ConfigurationBuilder 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

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