use of org.infinispan.configuration.cache.Configuration 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.infinispan.configuration.cache.Configuration 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.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildDefaultTimestampsRegion.
@Test
public void testBuildDefaultTimestampsRegion() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Properties p = createProperties();
InfinispanRegionFactory factory = createRegionFactory(p);
try {
assertTrue(isDefinedCache(factory, DEF_TIMESTAMPS_RESOURCE));
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
AdvancedCache cache = region.getCache();
assertEquals(timestamps, cache.getName());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
assertEquals(CacheMode.REPL_ASYNC, cacheCfg.clustering().cacheMode());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testConfigurationProcessing.
@Test
public void testConfigurationProcessing() {
final String person = "com.acme.Person";
final String addresses = "com.acme.Person.addresses";
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.com.acme.Person.cfg", "person-cache");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.eviction.strategy", "LRU");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.eviction.max_entries", "5000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.wake_up_interval", "2000");
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.com.acme.Person.addresses.cfg", "person-addresses-cache");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.lifespan", "120000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.max_idle", "60000");
p.setProperty("hibernate.cache.infinispan.query.cfg", "my-query-cache");
p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.query.expiration.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.query.eviction.max_entries", "10000");
TestInfinispanRegionFactory factory = createRegionFactory(p);
try {
assertEquals("person-cache", factory.getBaseConfiguration(person));
Configuration personOverride = factory.getConfigurationOverride(person);
assertEquals(EvictionStrategy.LRU, personOverride.eviction().strategy());
assertEquals(5000, personOverride.eviction().maxEntries());
assertEquals(2000, personOverride.expiration().wakeUpInterval());
assertEquals(60000, personOverride.expiration().lifespan());
assertEquals(30000, personOverride.expiration().maxIdle());
assertEquals("person-addresses-cache", factory.getBaseConfiguration(addresses));
Configuration addressesOverride = factory.getConfigurationOverride(addresses);
assertEquals(120000, addressesOverride.expiration().lifespan());
assertEquals(60000, addressesOverride.expiration().maxIdle());
assertEquals("my-query-cache", factory.getBaseConfiguration(DataType.QUERY));
Configuration queryOverride = factory.getConfigurationOverride(DataType.QUERY);
assertEquals(EvictionStrategy.LIRS, queryOverride.eviction().strategy());
assertEquals(10000, queryOverride.eviction().maxEntries());
assertEquals(3000, queryOverride.expiration().wakeUpInterval());
} finally {
factory.stop();
}
}
use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.
the class PutFromLoadValidatorUnitTest method testGetForNullReleasePuts.
@Test
@TestForIssue(jiraKey = "HHH-9928")
public void testGetForNullReleasePuts() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.simpleCache(true).expiration().maxIdle(500);
Configuration ppCfg = cb.build();
InfinispanRegionFactory regionFactory = mock(InfinispanRegionFactory.class);
doReturn(ppCfg).when(regionFactory).getPendingPutsCacheConfiguration();
doAnswer(invocation -> TIME_SERVICE.wallClockTime()).when(regionFactory).nextTimestamp();
PutFromLoadValidator testee = new PutFromLoadValidator(cache, regionFactory, cm);
for (int i = 0; i < 100; ++i) {
try {
withTx(tm, () -> {
SharedSessionContractImplementor session = mock(SharedSessionContractImplementor.class);
testee.registerPendingPut(session, KEY1, 0);
return null;
});
TIME_SERVICE.advance(10);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
String ppName = cm.getCache().getName() + "-" + InfinispanRegionFactory.DEF_PENDING_PUTS_RESOURCE;
Map ppCache = cm.getCache(ppName, false);
assertNotNull(ppCache);
Object pendingPutMap = ppCache.get(KEY1);
assertNotNull(pendingPutMap);
int size;
try {
Method sizeMethod = pendingPutMap.getClass().getMethod("size");
sizeMethod.setAccessible(true);
size = (Integer) sizeMethod.invoke(pendingPutMap);
} catch (Exception e) {
throw new RuntimeException(e);
}
// some of the pending puts need to be expired by now
assertTrue(size < 100);
// but some are still registered
assertTrue(size > 0);
}
Aggregations