HHH-10546 InfinispanRegionFactory should stop any caches it starts
This commit is contained in:
parent
627ecb97b0
commit
213478fc7d
|
@ -238,7 +238,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
private org.infinispan.transaction.lookup.TransactionManagerLookup transactionManagerlookup;
|
||||
private TransactionManager transactionManager;
|
||||
|
||||
private List<String> regionNames = new ArrayList<String>();
|
||||
private List<BaseRegion> regions = new ArrayList<BaseRegion>();
|
||||
private SessionFactoryOptions settings;
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, COLLECTION_KEY, properties, metadata);
|
||||
final CollectionRegionImpl region = new CollectionRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory() );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, metadata.isMutable() ? ENTITY_KEY : IMMUTABLE_ENTITY_KEY, properties, metadata );
|
||||
final EntityRegionImpl region = new EntityRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory() );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, NATURAL_ID_KEY, properties, metadata);
|
||||
final NaturalIdRegionImpl region = new NaturalIdRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory());
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
|
||||
final AdvancedCache cache = getCache( cacheName, QUERY_KEY, properties, null);
|
||||
final QueryResultsRegionImpl region = new QueryResultsRegionImpl( cache, regionName, transactionManager, this );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, TIMESTAMPS_KEY, properties, null);
|
||||
final TimestampsRegionImpl region = createTimestampsRegion( cache, regionName );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -430,8 +430,12 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
|
||||
protected void stopCacheRegions() {
|
||||
log.debug( "Clear region references" );
|
||||
getCacheCommandFactory().clearRegions( regionNames );
|
||||
regionNames.clear();
|
||||
getCacheCommandFactory().clearRegions( regions );
|
||||
// Ensure we cleanup any caches we created
|
||||
for ( BaseRegion region : regions ) {
|
||||
region.getCache().stop();
|
||||
}
|
||||
regions.clear();
|
||||
}
|
||||
|
||||
protected void stopCacheManager() {
|
||||
|
@ -528,9 +532,9 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
return new DefaultCacheManager( holder, true );
|
||||
}
|
||||
|
||||
private void startRegion(BaseRegion region, String regionName) {
|
||||
regionNames.add( regionName );
|
||||
getCacheCommandFactory().addRegion( regionName, region );
|
||||
private void startRegion(BaseRegion region) {
|
||||
regions.add( region );
|
||||
getCacheCommandFactory().addRegion( region );
|
||||
}
|
||||
|
||||
private Map<String, TypeOverrides> initGenericDataTypeOverrides() {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
@ -39,8 +39,8 @@ public class CacheCommandFactory implements ExtendedModuleCommandFactory {
|
|||
* @param regionName name of the region
|
||||
* @param region instance to keep track of
|
||||
*/
|
||||
public void addRegion(String regionName, BaseRegion region) {
|
||||
allRegions.put( regionName, region );
|
||||
public void addRegion(BaseRegion region) {
|
||||
allRegions.put( region.getName(), region );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,9 +48,9 @@ public class CacheCommandFactory implements ExtendedModuleCommandFactory {
|
|||
*
|
||||
* @param regionNames collection of regions to clear
|
||||
*/
|
||||
public void clearRegions(List<String> regionNames) {
|
||||
for ( String regionName : regionNames ) {
|
||||
allRegions.remove( regionName );
|
||||
public void clearRegions(Collection<BaseRegion> regions) {
|
||||
for ( BaseRegion region : regions ) {
|
||||
allRegions.remove( region.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue