HHH-10418 Only create validator if none associated with cache

This commit is contained in:
Galder Zamarreño 2017-12-06 10:03:53 +01:00 committed by Gail Badner
parent 33f8957474
commit 46f885b80c
2 changed files with 15 additions and 7 deletions

View File

@ -17,11 +17,7 @@ import org.hibernate.cache.infinispan.access.TombstoneCallInterceptor;
import org.hibernate.cache.infinispan.access.TxInvalidationCacheAccessDelegate; import org.hibernate.cache.infinispan.access.TxInvalidationCacheAccessDelegate;
import org.hibernate.cache.infinispan.access.UnorderedDistributionInterceptor; import org.hibernate.cache.infinispan.access.UnorderedDistributionInterceptor;
import org.hibernate.cache.infinispan.access.VersionedCallInterceptor; import org.hibernate.cache.infinispan.access.VersionedCallInterceptor;
import org.hibernate.cache.infinispan.util.Caches; import org.hibernate.cache.infinispan.util.*;
import org.hibernate.cache.infinispan.util.FutureUpdate;
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
import org.hibernate.cache.infinispan.util.Tombstone;
import org.hibernate.cache.infinispan.util.VersionedEntry;
import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CacheKeysFactory; import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.cache.spi.TransactionalDataRegion; import org.hibernate.cache.spi.TransactionalDataRegion;
@ -148,9 +144,17 @@ public abstract class BaseTransactionalDataRegion
assert strategy == Strategy.VALIDATION; assert strategy == Strategy.VALIDATION;
return; return;
} }
validator = new PutFromLoadValidator(cache, factory); synchronized (this) {
PutFromLoadValidator found = findValidator(cache);
validator = found != null ? found : new PutFromLoadValidator(cache, factory);
strategy = Strategy.VALIDATION; strategy = Strategy.VALIDATION;
} }
}
private PutFromLoadValidator findValidator(AdvancedCache cache) {
CacheCommandInitializer cmdInit = cache.getComponentRegistry().getComponent(CacheCommandInitializer.class);
return cmdInit.findPutFromLoadValidator(cache.getName());
}
protected void prepareForVersionedEntries() { protected void prepareForVersionedEntries() {
if (strategy != null) { if (strategy != null) {

View File

@ -48,6 +48,10 @@ public class CacheCommandInitializer implements ModuleCommandInitializer {
putFromLoadValidators.put(cacheName, putFromLoadValidator); putFromLoadValidators.put(cacheName, putFromLoadValidator);
} }
public PutFromLoadValidator findPutFromLoadValidator(String cacheName) {
return putFromLoadValidators.get(cacheName);
}
public PutFromLoadValidator removePutFromLoadValidator(String cacheName) { public PutFromLoadValidator removePutFromLoadValidator(String cacheName) {
return putFromLoadValidators.remove(cacheName); return putFromLoadValidators.remove(cacheName);
} }