Search in sources :

Example 1 with UnorderedReplicationLogic

use of org.infinispan.hibernate.cache.commons.access.UnorderedReplicationLogic in project infinispan by infinispan.

the class DomainDataRegionImpl method prepareCommon.

private void prepareCommon(CacheMode cacheMode) {
    BasicComponentRegistry registry = cache.getComponentRegistry().getComponent(BasicComponentRegistry.class);
    if (cacheMode.isReplicated() || cacheMode.isDistributed()) {
        AsyncInterceptorChain chain = cache.getAsyncInterceptorChain();
        LockingInterceptor lockingInterceptor = new LockingInterceptor();
        registry.registerComponent(LockingInterceptor.class, lockingInterceptor, true);
        registry.getComponent(LockingInterceptor.class).running();
        if (!chain.addInterceptorBefore(lockingInterceptor, NonTransactionalLockingInterceptor.class)) {
            throw new IllegalStateException("Misconfigured cache, interceptor chain is " + chain);
        }
        chain.removeInterceptor(NonTransactionalLockingInterceptor.class);
        UnorderedDistributionInterceptor distributionInterceptor = new UnorderedDistributionInterceptor();
        registry.registerComponent(UnorderedDistributionInterceptor.class, distributionInterceptor, true);
        registry.getComponent(UnorderedDistributionInterceptor.class).running();
        if (!chain.addInterceptorBefore(distributionInterceptor, NonTxDistributionInterceptor.class) && !chain.addInterceptorBefore(distributionInterceptor, TriangleDistributionInterceptor.class)) {
            throw new IllegalStateException("Misconfigured cache, interceptor chain is " + chain);
        }
        chain.removeInterceptor(NonTxDistributionInterceptor.class);
        chain.removeInterceptor(TriangleDistributionInterceptor.class);
    }
    // ClusteredExpirationManager sends RemoteExpirationCommands to remote nodes which causes
    // undesired overhead. When get() triggers a RemoteExpirationCommand executed in async executor
    // this locks the entry for the duration of RPC, and putFromLoad with ZERO_LOCK_ACQUISITION_TIMEOUT
    // fails as it finds the entry being blocked.
    ComponentRef<InternalExpirationManager> ref = registry.getComponent(InternalExpirationManager.class);
    InternalExpirationManager expirationManager = ref.running();
    if (expirationManager instanceof ClusterExpirationManager) {
        registry.replaceComponent(InternalExpirationManager.class.getName(), new ExpirationManagerImpl<>(), true);
        registry.getComponent(InternalExpirationManager.class).running();
        registry.rewire();
        // re-registering component does not stop the old one
        ((ClusterExpirationManager) expirationManager).stop();
    } else if (expirationManager instanceof ExpirationManagerImpl) {
    // do nothing
    } else {
        throw new IllegalStateException("Expected clustered expiration manager, found " + expirationManager);
    }
    registry.registerComponent(InfinispanDataRegion.class, this, true);
    if (cacheMode.isClustered()) {
        UnorderedReplicationLogic replLogic = new UnorderedReplicationLogic();
        registry.replaceComponent(ClusteringDependentLogic.class.getName(), replLogic, true);
        registry.getComponent(ClusteringDependentLogic.class).running();
        registry.rewire();
    }
}
Also used : ClusterExpirationManager(org.infinispan.expiration.impl.ClusterExpirationManager) NonTransactionalLockingInterceptor(org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor) LockingInterceptor(org.infinispan.hibernate.cache.commons.access.LockingInterceptor) AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain) UnorderedDistributionInterceptor(org.infinispan.hibernate.cache.commons.access.UnorderedDistributionInterceptor) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) NonTransactionalLockingInterceptor(org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor) UnorderedReplicationLogic(org.infinispan.hibernate.cache.commons.access.UnorderedReplicationLogic) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ExpirationManagerImpl(org.infinispan.expiration.impl.ExpirationManagerImpl)

Aggregations

ClusterExpirationManager (org.infinispan.expiration.impl.ClusterExpirationManager)1 ExpirationManagerImpl (org.infinispan.expiration.impl.ExpirationManagerImpl)1 InternalExpirationManager (org.infinispan.expiration.impl.InternalExpirationManager)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 LockingInterceptor (org.infinispan.hibernate.cache.commons.access.LockingInterceptor)1 UnorderedDistributionInterceptor (org.infinispan.hibernate.cache.commons.access.UnorderedDistributionInterceptor)1 UnorderedReplicationLogic (org.infinispan.hibernate.cache.commons.access.UnorderedReplicationLogic)1 AsyncInterceptorChain (org.infinispan.interceptors.AsyncInterceptorChain)1 ClusteringDependentLogic (org.infinispan.interceptors.locking.ClusteringDependentLogic)1 NonTransactionalLockingInterceptor (org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor)1