use of org.hibernate.cache.infinispan.entity.EntityRegionImpl 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.hibernate.cache.infinispan.entity.EntityRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testEnableStatistics.
@Test
public void testEnableStatistics() {
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.statistics", "true");
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.expiration.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
try {
EmbeddedCacheManager manager = factory.getCacheManager();
assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
AdvancedCache cache = region.getCache();
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
cache = region.getCache();
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
final String query = "org.hibernate.cache.internal.StandardQueryCache";
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
cache = queryRegion.getCache();
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
manager.defineConfiguration("timestamps", builder.build());
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
cache = timestampsRegion.getCache();
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
cache = collectionRegion.getCache();
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.entity.EntityRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildEntityCollectionRegionOverridesOnly.
@Test
public void testBuildEntityCollectionRegionOverridesOnly() {
final String address = "com.acme.Address";
final String personAddressses = "com.acme.Person.addresses";
AdvancedCache cache;
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "30000");
p.setProperty("hibernate.cache.infinispan.entity.expiration.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "35000");
p.setProperty("hibernate.cache.infinispan.collection.expiration.wake_up_interval", "3500");
TestInfinispanRegionFactory factory = createRegionFactory(p);
try {
factory.getCacheManager();
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(address, p, MUTABLE_NON_VERSIONED);
assertNull(factory.getBaseConfiguration(address));
cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(30000, cacheCfg.eviction().maxEntries());
// Max idle value comes from base XML configuration
assertEquals(100000, cacheCfg.expiration().maxIdle());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(personAddressses, p, MUTABLE_NON_VERSIONED);
assertNull(factory.getBaseConfiguration(personAddressses));
cache = collectionRegion.getCache();
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
assertEquals(35000, cacheCfg.eviction().maxEntries());
assertEquals(100000, cacheCfg.expiration().maxIdle());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.entity.EntityRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildImmutableEntityRegion.
@Test
public void testBuildImmutableEntityRegion() {
AdvancedCache cache;
Properties p = new Properties();
TestInfinispanRegionFactory factory = createRegionFactory(p);
try {
factory.getCacheManager();
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, IMMUTABLE_NON_VERSIONED);
assertNull(factory.getBaseConfiguration("com.acme.Address"));
cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals("Immutable entity should get non-transactional cache", TransactionMode.NON_TRANSACTIONAL, cacheCfg.transaction().transactionMode());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.entity.EntityRegionImpl in project hibernate-orm by hibernate.
the class NodeEnvironment method buildAndStoreEntityRegion.
private EntityRegionImpl buildAndStoreEntityRegion(String name, CacheDataDescription cacheDataDescription) {
EntityRegionImpl region = (EntityRegionImpl) regionFactory.buildEntityRegion(name, properties, cacheDataDescription);
entityRegionMap.put(name, region);
return region;
}
Aggregations