|
Hi,
In our webapp, we are using Ehcache as Hibernate cache region factory AND as method cache using Spring annotation @Cacheable. In our case we have single CacheManager with single ehcache.xml, which contains both kinds of regions - Hibernates and Springs. We are also using Terracotta for non Hibernates regions only.
When hibernate create CacheManager by hibernate.cache.region.factory_class, it is using HibernateUtil.loadAndCorrectConfiguration(url) method.
public static Configuration loadAndCorrectConfiguration(URL url) {
Configuration config = ConfigurationFactory.parseConfiguration( url );
if ( config.getDefaultCacheConfiguration().isTerracottaClustered() ) {
if ( ValueMode.IDENTITY
.equals( config.getDefaultCacheConfiguration().getTerracottaConfiguration().getValueMode() ) ) {
LOG.incompatibleCacheValueMode();
config.getDefaultCacheConfiguration()
.getTerracottaConfiguration()
.setValueMode( ValueMode.SERIALIZATION.name() );
}
setupHibernateTimeoutBehavior(
config.getDefaultCacheConfiguration()
.getTerracottaConfiguration()
.getNonstopConfiguration()
);
}
for ( CacheConfiguration cacheConfig : config.getCacheConfigurations().values() ) {
if ( cacheConfig.isTerracottaClustered() ) {
if ( ValueMode.IDENTITY.equals( cacheConfig.getTerracottaConfiguration().getValueMode() ) ) {
LOG.incompatibleCacheValueModePerCache( cacheConfig.getName() );
cacheConfig.getTerracottaConfiguration().setValueMode( ValueMode.SERIALIZATION.name() );
}
setupHibernateTimeoutBehavior( cacheConfig.getTerracottaConfiguration().getNonstopConfiguration() );
}
}
return config;
}
In this method NonstopCache timeout behavior is ALWAYS changing on 'exception', even if that region isn't Hibernates.
private static void setupHibernateTimeoutBehavior(NonstopConfiguration nonstopConfig) {
nonstopConfig.getTimeoutBehavior().setType( TimeoutBehaviorType.EXCEPTION.getTypeName() );
}
I think that better solution will be:
1) log WARN when that happend, and keep original behavior or 2) add property with list of regions names which allow for not default ('exception') timeout behavior.
What do you think about this?
|