use of org.infinispan.manager.EmbeddedCacheManager 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.infinispan.manager.EmbeddedCacheManager in project hibernate-orm by hibernate.
the class ClusterAwareRegionFactory method start.
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
cacheManagerName = properties.getProperty(DualNodeTest.NODE_ID_PROP);
EmbeddedCacheManager existing = getCacheManager(cacheManagerName);
locallyAdded = (existing == null);
if (locallyAdded) {
delegate.start(settings, properties);
cacheManagers.put(cacheManagerName, delegate.getCacheManager());
} else {
delegate.setCacheManager(existing);
}
}
use of org.infinispan.manager.EmbeddedCacheManager in project spring-boot by spring-projects.
the class InfinispanCacheConfiguration method infinispanCacheManager.
@Bean(destroyMethod = "stop")
@ConditionalOnMissingBean
public EmbeddedCacheManager infinispanCacheManager() throws IOException {
EmbeddedCacheManager cacheManager = createEmbeddedCacheManager();
List<String> cacheNames = this.cacheProperties.getCacheNames();
if (!CollectionUtils.isEmpty(cacheNames)) {
for (String cacheName : cacheNames) {
cacheManager.defineConfiguration(cacheName, getDefaultCacheConfiguration());
}
}
return cacheManager;
}
use of org.infinispan.manager.EmbeddedCacheManager in project wildfly by wildfly.
the class SharedInfinispanRegionFactory method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager(Properties properties, final ServiceRegistry serviceRegistry) {
String container = properties.getProperty(CACHE_CONTAINER, DEFAULT_CACHE_CONTAINER);
Properties cacheSettings = new Properties();
cacheSettings.put(HibernateSecondLevelCache.CONTAINER, container);
try {
// Get the (shared) cache manager for JPA application use
wrapper = Notification.startCache(Classification.INFINISPAN, cacheSettings);
return (EmbeddedCacheManager) wrapper.getValue();
} catch (Exception e) {
throw new CacheException(e);
}
}
use of org.infinispan.manager.EmbeddedCacheManager in project galley by Commonjava.
the class NFSOwnerCacheProducer method getCacheMgr.
public EmbeddedCacheManager getCacheMgr() {
final EmbeddedCacheManager cacheManager = new DefaultCacheManager(new GlobalConfigurationBuilder().globalJmxStatistics().jmxDomain("org.commonjava.maven.galley").build());
// Want to enable dead lock check as lock will be used in FastLocalCacheProvider
// and also set transaction mode to PESSIMISTIC with DummyTransactionManger.
final Configuration configuration = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU).size(1000).type(EvictionType.COUNT).deadlockDetection().spinDuration(10, TimeUnit.SECONDS).enable().transaction().transactionManagerLookup(new DummyTransactionManagerLookup()).lockingMode(LockingMode.PESSIMISTIC).build();
cacheManager.defineConfiguration(CACHE_NAME, configuration);
return cacheManager;
}
Aggregations