Search in sources :

Example 1 with InternalExpirationManager

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) {
        }
    });
}
Also used : Arrays(java.util.Arrays) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) LogFactory(org.infinispan.util.logging.LogFactory) EvictionManager(org.infinispan.eviction.EvictionManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) Metadata(org.infinispan.metadata.Metadata) Test(org.testng.annotations.Test) EvictionType(org.infinispan.eviction.EvictionType) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) CompletableFutures(org.infinispan.util.concurrent.CompletableFutures) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Log(org.infinispan.util.logging.Log) PassivationManagerStub(org.infinispan.eviction.impl.PassivationManagerStub) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) TestingUtil(org.infinispan.test.TestingUtil) ActivationManagerStub(org.infinispan.eviction.impl.ActivationManagerStub) DataContainer(org.infinispan.container.DataContainer) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) EmbeddedMetadata(org.infinispan.metadata.EmbeddedMetadata) DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) CompletionStage(java.util.concurrent.CompletionStage) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) TimeService(org.infinispan.commons.time.TimeService) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) TimeService(org.infinispan.commons.time.TimeService) PassivationManagerStub(org.infinispan.eviction.impl.PassivationManagerStub) CompletableFuture(java.util.concurrent.CompletableFuture) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) ActivationManagerStub(org.infinispan.eviction.impl.ActivationManagerStub) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) CompletionStage(java.util.concurrent.CompletionStage)

Example 2 with InternalExpirationManager

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();
    }
}
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)

Example 3 with InternalExpirationManager

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;
}
Also used : InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer) ActivationManager(org.infinispan.eviction.impl.ActivationManager) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) ControlledTimeService(org.infinispan.util.ControlledTimeService)

Aggregations

InternalExpirationManager (org.infinispan.expiration.impl.InternalExpirationManager)3 DefaultDataContainer (org.infinispan.container.impl.DefaultDataContainer)2 InternalEntryFactoryImpl (org.infinispan.container.impl.InternalEntryFactoryImpl)2 Arrays (java.util.Arrays)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 TimeService (org.infinispan.commons.time.TimeService)1 DataContainer (org.infinispan.container.DataContainer)1 InternalCacheEntry (org.infinispan.container.entries.InternalCacheEntry)1 EvictionManager (org.infinispan.eviction.EvictionManager)1 EvictionType (org.infinispan.eviction.EvictionType)1 ActivationManager (org.infinispan.eviction.impl.ActivationManager)1 ActivationManagerStub (org.infinispan.eviction.impl.ActivationManagerStub)1 PassivationManagerStub (org.infinispan.eviction.impl.PassivationManagerStub)1