use of org.hibernate.cache.infinispan.InfinispanRegionFactory in project hibernate-orm by hibernate.
the class AbstractEntityCollectionRegionTest method testGetCacheDataDescription.
@Test
public void testGetCacheDataDescription() throws Exception {
StandardServiceRegistryBuilder ssrb = CacheTestUtil.buildBaselineStandardServiceRegistryBuilder("test", InfinispanRegionFactory.class, true, false, jtaPlatform);
final StandardServiceRegistry registry = ssrb.build();
try {
Properties properties = CacheTestUtil.toProperties(ssrb.getSettings());
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(registry, getCacheTestSupport());
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", properties, getCacheDataDescription());
CacheDataDescription cdd = region.getCacheDataDescription();
assertNotNull(cdd);
CacheDataDescription expected = getCacheDataDescription();
assertEquals(expected.isMutable(), cdd.isMutable());
assertEquals(expected.isVersioned(), cdd.isVersioned());
assertEquals(expected.getVersionComparator(), cdd.getVersionComparator());
} finally {
StandardServiceRegistryBuilder.destroy(registry);
}
}
use of org.hibernate.cache.infinispan.InfinispanRegionFactory in project hibernate-orm by hibernate.
the class AbstractNonInvalidationTest method startUp.
@Override
protected void startUp() {
super.startUp();
InfinispanRegionFactory regionFactory = (InfinispanRegionFactory) sessionFactory().getSettings().getRegionFactory();
TIMEOUT = regionFactory.getPendingPutsCacheConfiguration().expiration().maxIdle();
region = sessionFactory().getSecondLevelCacheRegion(Item.class.getName());
entityCache = ((EntityRegionImpl) region).getCache();
}
use of org.hibernate.cache.infinispan.InfinispanRegionFactory 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.InfinispanRegionFactory 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.InfinispanRegionFactory 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