use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testBuildDiffCacheNameTimestampsRegion.
@Test
public void testBuildDiffCacheNameTimestampsRegion() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
final String unrecommendedTimestamps = "unrecommended-timestamps";
Properties p = createProperties();
p.setProperty(TIMESTAMPS_CACHE_RESOURCE_PROP, unrecommendedTimestamps);
TestInfinispanRegionFactory factory = createRegionFactory(p, (f, m) -> {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
m.defineConfiguration(unrecommendedTimestamps, builder.build());
});
try {
assertEquals(unrecommendedTimestamps, factory.getBaseConfiguration(DataType.TIMESTAMPS));
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
assertEquals(CacheMode.REPL_SYNC, cacheCfg.clustering().cacheMode());
assertFalse(cacheCfg.storeAsBinary().enabled());
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 testBuildTimestampsRegionWithCacheNameOverride.
@Test
public void testBuildTimestampsRegionWithCacheNameOverride() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
final String myTimestampsCache = "mytimestamps-cache";
Properties p = createProperties();
p.setProperty(TIMESTAMPS_CACHE_RESOURCE_PROP, myTimestampsCache);
InfinispanRegionFactory factory = createRegionFactory(p, (f, m) -> {
ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL);
m.defineConfiguration(myTimestampsCache, builder.build());
});
try {
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
assertTrue(isDefinedCache(factory, timestamps));
// default timestamps cache is async replicated
assertEquals(CacheMode.LOCAL, region.getCache().getCacheConfiguration().clustering().cacheMode());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testDisableStatistics.
@Test
public void testDisableStatistics() {
Properties p = createProperties();
p.setProperty("hibernate.cache.infinispan.statistics", "false");
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 {
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
AdvancedCache cache = region.getCache();
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
cache = region.getCache();
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
final String query = "org.hibernate.cache.internal.StandardQueryCache";
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
cache = queryRegion.getCache();
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
factory.getCacheManager().defineConfiguration("timestamps", builder.build());
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
cache = timestampsRegion.getCache();
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
cache = collectionRegion.getCache();
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
} finally {
factory.stop();
}
}
use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.
the class TimestampsRegionImplTest method testClearTimestampsRegionInIsolated.
public void testClearTimestampsRegionInIsolated() throws Exception {
StandardServiceRegistryBuilder ssrb = createStandardServiceRegistryBuilder();
final StandardServiceRegistry registry = ssrb.build();
final StandardServiceRegistry registry2 = ssrb.build();
try {
final Properties properties = CacheTestUtil.toProperties(ssrb.getSettings());
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(registry, getCacheTestSupport());
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(registry2, getCacheTestSupport());
TimestampsRegionImpl region = (TimestampsRegionImpl) regionFactory.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), properties);
TimestampsRegionImpl region2 = (TimestampsRegionImpl) regionFactory2.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), properties);
Account acct = new Account();
acct.setAccountHolder(new AccountHolder());
region.getCache().withFlags(Flag.FORCE_SYNCHRONOUS).put(acct, "boo");
} finally {
StandardServiceRegistryBuilder.destroy(registry);
StandardServiceRegistryBuilder.destroy(registry2);
}
}
Aggregations