Author: galder.zamarreno(a)jboss.com
Date: 2010-07-05 10:30:38 -0400 (Mon, 05 Jul 2010)
New Revision: 19896
Modified:
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
Log:
[HHH-5260] (Allow query region name specific eviction settings) Done.
Modified:
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
===================================================================
---
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2010-07-04
19:47:28 UTC (rev 19895)
+++
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2010-07-05
14:30:38 UTC (rev 19896)
@@ -99,7 +99,7 @@
/**
* Name of the configuration that should be used for timestamp caches.
*
- * @see #DEF_TS_RESOURCE
+ * @see #DEF_TIMESTAMPS_RESOURCE
*/
public static final String TIMESTAMPS_CACHE_RESOURCE_PROP = PREFIX + TIMESTAMPS_KEY +
CONFIG_SUFFIX;
@@ -113,7 +113,7 @@
public static final String QUERY_CACHE_RESOURCE_PROP = PREFIX + QUERY_KEY +
CONFIG_SUFFIX;
/**
- * Default value for {@link #INFINISPAN_RESOURCE_PROP}. Specifies the
"infinispan-configs.xml" file in this package.
+ * Default value for {@link #INFINISPAN_CONFIG_RESOURCE_PROP}. Specifies the
"infinispan-configs.xml" file in this package.
*/
public static final String DEF_INFINISPAN_CONFIG_RESOURCE =
"org/hibernate/cache/infinispan/builder/infinispan-configs.xml";
@@ -183,8 +183,8 @@
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties
properties)
throws CacheException {
if (log.isDebugEnabled()) log.debug("Building query results cache region
[" + regionName + "]");
- String cacheName = typeOverrides.get(QUERY_KEY).getCacheName();
- CacheAdapter cacheAdapter =
CacheAdapterImpl.newInstance(manager.getCache(cacheName));
+ Cache cache = getCache(regionName, QUERY_KEY, properties);
+ CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(cache);
QueryResultsRegionImpl region = new QueryResultsRegionImpl(cacheAdapter,
regionName, properties, transactionManager, this);
region.start();
return region;
Modified:
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
===================================================================
---
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java 2010-07-04
19:47:28 UTC (rev 19895)
+++
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java 2010-07-05
14:30:38 UTC (rev 19896)
@@ -415,6 +415,32 @@
}
}
+ public void testBuildQueryRegionWithCustomRegionName() {
+ final String queryRegionName = "myquery";
+ Properties p = new Properties();
+ InfinispanRegionFactory factory = new InfinispanRegionFactory();
+ p.setProperty("hibernate.cache.infinispan.myquery.cfg",
"timestamps-none-eviction");
+ p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy",
"FIFO");
+
p.setProperty("hibernate.cache.infinispan.myquery.eviction.wake_up_interval",
"2222");
+ p.setProperty("hibernate.cache.infinispan.myquery.eviction.max_entries",
"11111");
+ factory.start(null, p);
+ CacheManager manager = factory.getCacheManager();
+ manager.getGlobalConfiguration().setTransportClass(null);
+ try {
+
assertTrue(factory.getDefinedConfigurations().contains("local-query"));
+ QueryResultsRegionImpl region = (QueryResultsRegionImpl)
factory.buildQueryResultsRegion(queryRegionName, p);
+ assertNotNull(factory.getTypeOverrides().get(queryRegionName));
+ assertTrue(factory.getDefinedConfigurations().contains(queryRegionName));
+ CacheAdapter cache = region.getCacheAdapter();
+ Configuration cacheCfg = cache.getConfiguration();
+ assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
+ assertEquals(2222, cacheCfg.getEvictionWakeUpInterval());
+ assertEquals(11111, cacheCfg.getEvictionMaxEntries());
+ } finally {
+ factory.stop();
+ }
+ }
+
public void testEnableStatistics() {
Properties p = new Properties();
p.setProperty("hibernate.cache.infinispan.statistics",
"true");
Show replies by date