use of org.infinispan.configuration.cache.Configuration in project galley by Commonjava.
the class NFSOwnerCacheProducer method getCacheMgr.
public EmbeddedCacheManager getCacheMgr() {
final EmbeddedCacheManager cacheManager = new DefaultCacheManager(new GlobalConfigurationBuilder().globalJmxStatistics().jmxDomain("org.commonjava.maven.galley").build());
// Want to enable dead lock check as lock will be used in FastLocalCacheProvider
// and also set transaction mode to PESSIMISTIC with DummyTransactionManger.
final Configuration configurationForNfs = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU).size(1000).type(EvictionType.COUNT).deadlockDetection().spinDuration(10, TimeUnit.SECONDS).enable().transaction().transactionManagerLookup(new DummyTransactionManagerLookup()).lockingMode(LockingMode.PESSIMISTIC).build();
cacheManager.defineConfiguration(CACHE_NAME, configurationForNfs);
// Default cache impl for the local file cache in FLCP, uses 7 day as an expiration duration, and trigger purge every 30 mins.
final Long expirationDuration = 7 * 24 * 3600 * 1000L;
Configuration configForLocalFile = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU).size(20000).type(EvictionType.COUNT).expiration().lifespan(expirationDuration).wakeUpInterval(30 * 60 * 1000L).maxIdle(expirationDuration).build();
cacheManager.defineConfiguration(DEFAULT_LOCAL_CACHE_FILE_NAME, configForLocalFile);
// A test cache impl to do unit-testing for this local file cache expiration for purging mechanism
Configuration configForLocalFileTest = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU).size(1000).type(EvictionType.COUNT).expiration().lifespan(1000L).wakeUpInterval(100L).maxIdle(1000L).build();
cacheManager.defineConfiguration(LOCAL_CACHE_FILE_NAME_FOR_TEST, configForLocalFileTest);
return cacheManager;
}
use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.
the class DefaultCacheContainerTestCase method getDefaultCacheConfiguration.
@Test
public void getDefaultCacheConfiguration() {
Configuration config = new ConfigurationBuilder().build();
when(this.manager.getDefaultCacheConfiguration()).thenReturn(config);
Configuration result = this.subject.getDefaultCacheConfiguration();
assertSame(config, result);
}
use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.
the class DefaultCacheContainerTestCase method getCacheConfiguration.
@Test
public void getCacheConfiguration() {
Configuration config = new ConfigurationBuilder().build();
when(this.manager.getCacheConfiguration("cache")).thenReturn(config);
Configuration result = this.subject.getCacheConfiguration("cache");
assertSame(config, result);
}
use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.
the class ConfigurationServiceConfigurator method get.
@Override
public Configuration get() {
ConfigurationBuilder builder = new ConfigurationBuilder();
this.consumer.accept(builder);
// Auto-enable simple cache optimization if cache is local, on-heap, non-transactional, and non-persistent, and statistics are disabled
builder.simpleCache((builder.clustering().cacheMode() == CacheMode.LOCAL) && (builder.memory().storage() == StorageType.HEAP) && !builder.transaction().transactionMode().isTransactional() && builder.persistence().stores().isEmpty() && !builder.statistics().create().enabled());
builder.encoding().mediaType(builder.memory().storage() == StorageType.OFF_HEAP ? this.container.get().getCacheManagerConfiguration().serialization().marshaller().mediaType().toString() : MediaType.APPLICATION_OBJECT_TYPE);
Configuration configuration = builder.build();
EmbeddedCacheManager container = this.container.get();
container.defineConfiguration(this.cacheName, configuration);
return configuration;
}
use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.
the class CacheEntryMutatorTestCase method mutateTransactional.
@Test
public void mutateTransactional() {
AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
Object id = new Object();
Object value = new Object();
Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.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(1)).put(same(id), same(value));
mutator.mutate();
verify(cache, times(1)).put(same(id), same(value));
}
Aggregations