use of org.infinispan.expiration.ExpirationManager 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);
}
}
use of org.infinispan.expiration.ExpirationManager in project infinispan by infinispan.
the class AutoCommitExpiryTest method testNoAutCommitAndExpiryListener.
@Test
public void testNoAutCommitAndExpiryListener() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
ExpiryListener expiryListener = new ExpiryListener();
Cache<String, String> applicationCache = cacheManager.getCache();
applicationCache.addListener(expiryListener);
TransactionManager tm = applicationCache.getAdvancedCache().getTransactionManager();
tm.begin();
applicationCache.put("test1", "value1", 1, TimeUnit.SECONDS);
tm.commit();
tm.begin();
applicationCache.put("test2", "value2", 1, TimeUnit.SECONDS);
tm.commit();
timeService.advance(TimeUnit.SECONDS.toMillis(10));
ExpirationManager manager = applicationCache.getAdvancedCache().getExpirationManager();
manager.processExpiration();
assertEquals(2, expiryListener.getCount());
}
Aggregations