use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method buildTimestampsRegion.
@Override
public TimestampsRegion buildTimestampsRegion(String regionName, Map<String, Object> configValues) {
if (log.isDebugEnabled()) {
log.debug("Building timestamps cache region [" + regionName + "]");
}
final AdvancedCache cache = getCache(regionName, DataType.TIMESTAMPS, null);
final TimestampsRegionImpl region = createTimestampsRegion(cache, regionName);
startRegion(region);
return region;
}
use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildTimestampsRegionWithNoneEvictionOverride.
@Test
public void testBuildTimestampsRegionWithNoneEvictionOverride() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
final String timestampsNoEviction = "timestamps-no-eviction";
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", timestampsNoEviction);
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "0");
p.setProperty("hibernate.cache.infinispan.timestamps.expiration.wake_up_interval", "3000");
InfinispanRegionFactory factory = createRegionFactory(p);
try {
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
assertTrue(isDefinedCache(factory, timestamps));
assertEquals(3000, region.getCache().getCacheConfiguration().expiration().wakeUpInterval());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl 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.timestamp.TimestampsRegionImpl 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.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testTimestampValidation.
@Test(expected = CacheException.class)
public void testTimestampValidation() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Properties p = createProperties();
InputStream configStream = FileLookupFactory.newInstance().lookupFile(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE, getClass().getClassLoader());
ConfigurationBuilderHolder cbh = new ParserRegistry().parse(configStream);
DefaultCacheManager manager = new DefaultCacheManager(cbh, true);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
manager.defineConfiguration(DEF_TIMESTAMPS_RESOURCE, builder.build());
try {
InfinispanRegionFactory factory = createRegionFactory(manager, p, null);
factory.start(CacheTestUtil.sfOptionsForStart(), p);
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
} finally {
TestingUtil.killCacheManagers(manager);
}
}
Aggregations