HHH-10546 InfinispanRegionFactory should stop any caches it starts
This commit is contained in:
parent
b03947e4a5
commit
58c6c7a98a
|
@ -280,7 +280,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<>();
|
||||
private SessionFactoryOptions settings;
|
||||
|
||||
private Boolean globalStats;
|
||||
|
@ -310,7 +310,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, DataType.COLLECTION, metadata);
|
||||
final CollectionRegionImpl region = new CollectionRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory() );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, metadata.isMutable() ? DataType.ENTITY : DataType.IMMUTABLE_ENTITY, metadata );
|
||||
final EntityRegionImpl region = new EntityRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory() );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, DataType.NATURAL_ID, metadata);
|
||||
final NaturalIdRegionImpl region = new NaturalIdRegionImpl( cache, regionName, transactionManager, metadata, this, buildCacheKeysFactory());
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
|
||||
final AdvancedCache cache = getCache( regionName, DataType.QUERY, null);
|
||||
final QueryResultsRegionImpl region = new QueryResultsRegionImpl( cache, regionName, transactionManager, this );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
final AdvancedCache cache = getCache( regionName, DataType.TIMESTAMPS, null);
|
||||
final TimestampsRegionImpl region = createTimestampsRegion( cache, regionName );
|
||||
startRegion( region, regionName );
|
||||
startRegion( region );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
@ -495,8 +495,13 @@ 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
|
||||
regions.forEach( region -> {
|
||||
region.getCache().stop();
|
||||
manager.undefineConfiguration( region.getCache().getName() );
|
||||
} );
|
||||
regions.clear();
|
||||
}
|
||||
|
||||
protected void stopCacheManager() {
|
||||
|
@ -554,9 +559,9 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
}
|
||||
|
||||
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 void parseProperty(int prefixLoc, String key, String value) {
|
||||
|
|
|
@ -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,10 +48,8 @@ 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) {
|
||||
regions.forEach( region -> allRegions.remove( region.getName() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue