Search in sources :

Example 1 with UnorderedDistributionInterceptor

use of org.hibernate.cache.infinispan.access.UnorderedDistributionInterceptor in project hibernate-orm by hibernate.

the class BaseTransactionalDataRegion method replaceCommonInterceptors.

private void replaceCommonInterceptors() {
    CacheMode cacheMode = cache.getCacheConfiguration().clustering().cacheMode();
    if (!cacheMode.isReplicated() && !cacheMode.isDistributed()) {
        return;
    }
    LockingInterceptor lockingInterceptor = new LockingInterceptor();
    cache.getComponentRegistry().registerComponent(lockingInterceptor, LockingInterceptor.class);
    if (!cache.addInterceptorBefore(lockingInterceptor, NonTransactionalLockingInterceptor.class)) {
        throw new IllegalStateException("Misconfigured cache, interceptor chain is " + cache.getInterceptorChain());
    }
    cache.removeInterceptor(NonTransactionalLockingInterceptor.class);
    UnorderedDistributionInterceptor distributionInterceptor = new UnorderedDistributionInterceptor();
    cache.getComponentRegistry().registerComponent(distributionInterceptor, UnorderedDistributionInterceptor.class);
    if (!cache.addInterceptorBefore(distributionInterceptor, NonTxDistributionInterceptor.class)) {
        throw new IllegalStateException("Misconfigured cache, interceptor chain is " + cache.getInterceptorChain());
    }
    cache.removeInterceptor(NonTxDistributionInterceptor.class);
    EntryWrappingInterceptor ewi = cache.getComponentRegistry().getComponent(EntryWrappingInterceptor.class);
    try {
        Field isUsingLockDelegation = EntryWrappingInterceptor.class.getDeclaredField("isUsingLockDelegation");
        isUsingLockDelegation.setAccessible(true);
        isUsingLockDelegation.set(ewi, false);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new IllegalStateException(e);
    }
}
Also used : Field(java.lang.reflect.Field) NonTransactionalLockingInterceptor(org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor) LockingInterceptor(org.hibernate.cache.infinispan.access.LockingInterceptor) NonTxDistributionInterceptor(org.infinispan.interceptors.distribution.NonTxDistributionInterceptor) UnorderedDistributionInterceptor(org.hibernate.cache.infinispan.access.UnorderedDistributionInterceptor) EntryWrappingInterceptor(org.infinispan.interceptors.EntryWrappingInterceptor) NonTransactionalLockingInterceptor(org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor) CacheMode(org.infinispan.configuration.cache.CacheMode)

Aggregations

Field (java.lang.reflect.Field)1 LockingInterceptor (org.hibernate.cache.infinispan.access.LockingInterceptor)1 UnorderedDistributionInterceptor (org.hibernate.cache.infinispan.access.UnorderedDistributionInterceptor)1 CacheMode (org.infinispan.configuration.cache.CacheMode)1 EntryWrappingInterceptor (org.infinispan.interceptors.EntryWrappingInterceptor)1 NonTxDistributionInterceptor (org.infinispan.interceptors.distribution.NonTxDistributionInterceptor)1 NonTransactionalLockingInterceptor (org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor)1