use of org.infinispan.configuration.cache.Configuration in project jetty.project by eclipse.
the class InfinispanTestSupport method setup.
public void setup() throws Exception {
if (_useFileStore) {
_tmpdir = File.createTempFile("infini", "span");
_tmpdir.delete();
_tmpdir.mkdir();
Configuration config = _builder.persistence().addSingleFileStore().location(_tmpdir.getAbsolutePath()).storeAsBinary().build();
_manager.defineConfiguration(_name, config);
} else {
_manager.defineConfiguration(_name, _builder.build());
}
_cache = _manager.getCache(_name);
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method getCache.
protected AdvancedCache getCache(String regionName, DataType type, CacheDataDescription metadata) {
if (!manager.cacheExists(regionName)) {
String templateCacheName = baseConfigurations.get(regionName);
Configuration configuration = null;
ConfigurationBuilder builder = new ConfigurationBuilder();
if (templateCacheName != null) {
configuration = manager.getCacheConfiguration(templateCacheName);
if (configuration == null) {
log.customConfigForRegionNotFound(templateCacheName, regionName, type.key);
} else {
log.debugf("Region '%s' will use cache template '%s'", regionName, templateCacheName);
builder.read(configuration);
configureTransactionManager(builder);
// do not apply data type overrides to regions that set special cache configuration
}
}
if (configuration == null) {
configuration = dataTypeConfigurations.get(type);
if (configuration == null) {
throw new IllegalStateException("Configuration not defined for type " + type.key);
}
builder.read(configuration);
// overrides for data types are already applied, but we should check custom ones
}
ConfigurationBuilder override = configOverrides.get(regionName);
if (override != null) {
log.debugf("Region '%s' has additional configuration set through properties.", regionName);
builder.read(override.build(false));
}
if (getCacheKeysFactory() instanceof SimpleCacheKeysFactory) {
// the keys may not define hashCode/equals correctly (e.g. arrays)
if (metadata != null && metadata.getKeyType() != null) {
builder.dataContainer().keyEquivalence(new TypeEquivalance(metadata.getKeyType()));
}
}
if (globalStats != null) {
builder.jmxStatistics().enabled(globalStats).available(globalStats);
}
configuration = builder.build();
type.validate(configuration);
manager.defineConfiguration(regionName, configuration);
}
final AdvancedCache cache = manager.getCache(regionName).getAdvancedCache();
// TODO: not sure if this is needed in recent Infinispan
if (!cache.getStatus().allowInvocations()) {
cache.start();
}
return createCacheWrapper(cache);
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildEntityRegionPersonPlusEntityOverridesWithoutCfg.
@Test
public void testBuildEntityRegionPersonPlusEntityOverridesWithoutCfg() {
final String person = "com.acme.Person";
Properties p = createProperties();
// Third option, no cache defined for entity and overrides for generic entity data type and entity itself.
p.setProperty("hibernate.cache.infinispan.com.acme.Person.eviction.strategy", "LRU");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
p.setProperty("hibernate.cache.infinispan.entity.expiration.wake_up_interval", "3000");
TestInfinispanRegionFactory factory = createRegionFactory(p);
try {
factory.getCacheManager();
assertFalse(isDefinedCache(factory, person));
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, MUTABLE_NON_VERSIONED);
assertTrue(isDefinedCache(factory, person));
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(10000, cacheCfg.eviction().maxEntries());
assertEquals(60000, cacheCfg.expiration().lifespan());
assertEquals(30000, cacheCfg.expiration().maxIdle());
} finally {
factory.stop();
}
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildQueryRegionWithCustomRegionName.
@Test
public void testBuildQueryRegionWithCustomRegionName() {
final String queryRegionName = "myquery";
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.myquery.cfg", "timestamps-none-eviction");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.myquery.expiration.wake_up_interval", "2222");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.max_entries", "11111");
TestInfinispanRegionFactory factory = createRegionFactory(p);
try {
assertTrue(isDefinedCache(factory, "local-query"));
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(queryRegionName, p);
assertNotNull(factory.getBaseConfiguration(queryRegionName));
assertTrue(isDefinedCache(factory, queryRegionName));
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(2222, cacheCfg.expiration().wakeUpInterval());
assertEquals(11111, cacheCfg.eviction().maxEntries());
} finally {
factory.stop();
}
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildQueryRegion.
@Test
public void testBuildQueryRegion() {
final String query = "org.hibernate.cache.internal.StandardQueryCache";
Properties p = createProperties();
InfinispanRegionFactory factory = createRegionFactory(p);
try {
assertTrue(isDefinedCache(factory, "local-query"));
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(CacheMode.LOCAL, cacheCfg.clustering().cacheMode());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
}
Aggregations