use of org.infinispan.expiration.impl.ClusterExpirationManager 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();
}
}
use of org.infinispan.expiration.impl.ClusterExpirationManager in project hibernate-orm by hibernate.
the class BaseTransactionalDataRegion method replaceExpirationManager.
private void replaceExpirationManager() {
// 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.
ExpirationManager expirationManager = cache.getComponentRegistry().getComponent(ExpirationManager.class);
if ((expirationManager instanceof ClusterExpirationManager)) {
// re-registering component does not stop the old one
((ClusterExpirationManager) expirationManager).stop();
cache.getComponentRegistry().registerComponent(new ExpirationManagerImpl<>(), ExpirationManager.class);
cache.getComponentRegistry().rewire();
} else if (expirationManager instanceof ExpirationManagerImpl) {
// do nothing
} else {
throw new IllegalStateException("Expected clustered expiration manager, found " + expirationManager);
}
}
Aggregations