use of org.infinispan.expiration.impl.InternalExpirationManager in project infinispan by infinispan.
the class DataContainerStressTest method initializeDefaultDataContainer.
private void initializeDefaultDataContainer(DefaultDataContainer dc) {
InternalEntryFactoryImpl entryFactory = new InternalEntryFactoryImpl();
TimeService timeService = new EmbeddedTimeService();
TestingUtil.inject(entryFactory, timeService);
// Mockito cannot be used as it will run out of memory from keeping all the invocations, thus we use blank impls
TestingUtil.inject(dc, (EvictionManager) (evicted, cmd) -> CompletableFutures.completedNull(), new PassivationManagerStub(), entryFactory, new ActivationManagerStub(), null, timeService, null, new InternalExpirationManager() {
@Override
public void processExpiration() {
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public CompletableFuture<Boolean> entryExpiredInMemory(InternalCacheEntry entry, long currentTime, boolean writeOperation) {
return null;
}
@Override
public CompletionStage<Void> handleInStoreExpirationInternal(Object key) {
return null;
}
@Override
public CompletionStage<Void> handleInStoreExpirationInternal(MarshallableEntry marshalledEntry) {
return null;
}
@Override
public CompletionStage<Boolean> handlePossibleExpiration(InternalCacheEntry entry, int segment, boolean isWrite) {
return null;
}
@Override
public void addInternalListener(ExpirationConsumer consumer) {
}
@Override
public void removeInternalListener(Object listener) {
}
});
}
use of org.infinispan.expiration.impl.InternalExpirationManager 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.InternalExpirationManager in project infinispan by infinispan.
the class SimpleDataContainerTest method createContainer.
protected DataContainer<String, String> createContainer() {
DefaultDataContainer<String, String> dc = new DefaultDataContainer<>(16);
InternalEntryFactoryImpl internalEntryFactory = new InternalEntryFactoryImpl();
timeService = new ControlledTimeService();
TestingUtil.inject(internalEntryFactory, timeService);
ActivationManager activationManager = mock(ActivationManager.class);
InternalExpirationManager expirationManager = mock(InternalExpirationManager.class);
Mockito.when(expirationManager.entryExpiredInMemory(Mockito.any(), Mockito.anyLong(), Mockito.anyBoolean())).thenReturn(CompletableFutures.completedTrue());
TestingUtil.inject(dc, internalEntryFactory, timeService, expirationManager);
return dc;
}
Aggregations