Search in sources :

Example 1 with PassivationManager

use of org.infinispan.eviction.impl.PassivationManager in project wildfly by wildfly.

the class WildFlyInfinispanModuleLifecycle method cacheStarting.

@Override
public void cacheStarting(ComponentRegistry registry, Configuration configuration, String cacheName) {
    PersistenceConfiguration persistence = configuration.persistence();
    // If we purge passivation stores on startup, passivating entries on stop is a waste of time
    if (persistence.usingStores() && persistence.passivation()) {
        PassivationManager passivation = registry.getLocalComponent(PassivationManager.class);
        passivation.skipPassivationOnStop(persistence.stores().stream().allMatch(StoreConfiguration::purgeOnStartup));
    }
    registry.getLocalComponent(PersistenceManager.class).setClearOnStop(false);
}
Also used : PassivationManager(org.infinispan.eviction.impl.PassivationManager) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) PersistenceManager(org.infinispan.persistence.manager.PersistenceManager)

Example 2 with PassivationManager

use of org.infinispan.eviction.impl.PassivationManager in project wildfly by wildfly.

the class WildFlyInfinispanModuleLifecycle method cacheStarting.

@Override
public void cacheStarting(ComponentRegistry registry, Configuration configuration, String cacheName) {
    PersistenceConfiguration persistence = configuration.persistence();
    // If we purge passivation stores on startup, passivating entries on stop is a waste of time
    if (persistence.usingStores() && persistence.passivation()) {
        PassivationManager passivation = registry.getLocalComponent(PassivationManager.class);
        passivation.skipPassivationOnStop(persistence.stores().stream().allMatch(StoreConfiguration::purgeOnStartup));
    }
    registry.getLocalComponent(PersistenceManager.class).setClearOnStop(false);
}
Also used : PassivationManager(org.infinispan.eviction.impl.PassivationManager) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) PersistenceManager(org.infinispan.persistence.manager.PersistenceManager)

Example 3 with PassivationManager

use of org.infinispan.eviction.impl.PassivationManager in project infinispan by infinispan.

the class CacheNotifierPersistenceFilterTest method testPassivationBlocked.

@Test
public void testPassivationBlocked() {
    String key = "key";
    String value = "value";
    Cache<String, String> cache0 = cache(0, CACHE_NAME);
    AllCacheEntryListener listener = new AllCacheEntryListener();
    cache0.addListener(listener, new EventKeyFilter(Event.Type.CACHE_ENTRY_PASSIVATED, key), null);
    PassivationManager passivationManager = cache0.getAdvancedCache().getComponentRegistry().getComponent(PassivationManager.class);
    CompletionStages.join(passivationManager.passivateAsync(new ImmortalCacheEntry(key, value)));
    assertEquals(2, listener.events.size());
    assertEquals(Event.Type.CACHE_ENTRY_PASSIVATED, listener.events.get(0).getType());
    assertEquals(key, listener.events.get(0).getKey());
    assertEquals(value, listener.events.get(0).getValue());
    assertEquals(Event.Type.CACHE_ENTRY_PASSIVATED, listener.events.get(1).getType());
    assertEquals(key, listener.events.get(1).getKey());
    assertNull(listener.events.get(1).getValue());
    CompletionStages.join(passivationManager.passivateAsync(new ImmortalCacheEntry("not" + key, value)));
    // We shouldn't have received any additional events
    assertEquals(2, listener.events.size());
}
Also used : PassivationManager(org.infinispan.eviction.impl.PassivationManager) ImmortalCacheEntry(org.infinispan.container.entries.ImmortalCacheEntry) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 4 with PassivationManager

use of org.infinispan.eviction.impl.PassivationManager in project infinispan by infinispan.

the class CacheNotifierPersistenceFilterTest method testActivationBlocked.

@Test
public void testActivationBlocked() {
    String key = "key";
    String value = "value";
    Cache<String, String> cache0 = cache(0, CACHE_NAME);
    PassivationManager passivationManager = cache0.getAdvancedCache().getComponentRegistry().getComponent(PassivationManager.class);
    // Passivate 2 entries to resurrect
    CompletionStages.join(passivationManager.passivateAsync(new ImmortalCacheEntry(key, value)));
    CompletionStages.join(passivationManager.passivateAsync(new ImmortalCacheEntry("not" + key, value)));
    AllCacheEntryListener listener = new AllCacheEntryListener();
    cache0.addListener(listener, new EventKeyFilter(Event.Type.CACHE_ENTRY_ACTIVATED, key), null);
    assertEquals(value, cache0.get("not" + key));
    // We shouldn't have received any events
    assertEquals(0, listener.events.size());
    assertEquals(value, cache0.get(key));
    assertEquals(2, listener.events.size());
    assertEquals(Event.Type.CACHE_ENTRY_ACTIVATED, listener.events.get(0).getType());
    assertEquals(key, listener.events.get(0).getKey());
    assertEquals(value, listener.events.get(0).getValue());
    assertEquals(Event.Type.CACHE_ENTRY_ACTIVATED, listener.events.get(0).getType());
    assertEquals(key, listener.events.get(1).getKey());
    assertEquals(value, listener.events.get(1).getValue());
}
Also used : PassivationManager(org.infinispan.eviction.impl.PassivationManager) ImmortalCacheEntry(org.infinispan.container.entries.ImmortalCacheEntry) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 5 with PassivationManager

use of org.infinispan.eviction.impl.PassivationManager in project infinispan by infinispan.

the class ServerEventLoggerTest method testCacheContentCanBePassivated.

@Test
public void testCacheContentCanBePassivated() {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    GlobalConfigurationBuilder globalBuilder = amendGlobalConfiguration(GlobalConfigurationBuilder.defaultClusteredBuilder());
    globalBuilder.globalState().enable();
    deleteGlobalPersistentState(globalBuilder);
    withCacheManager(TestCacheManagerFactory.createClusteredCacheManager(globalBuilder, builder), cm -> {
        EventLogger eventLogger = EventLogManager.getEventLogger(cm);
        eventLogger.info(EventLogCategory.CLUSTER, "message #1");
        // Wait for the event to be inserted in the even log cache
        waitForEvents(1, eventLogger, EventLogCategory.CLUSTER, null);
        Cache<UUID, ServerEventImpl> cache = cm.getCache(ServerEventLogger.EVENT_LOG_CACHE);
        PassivationManager passivationManager = TestingUtil.extractComponent(cache, PassivationManager.class);
        CompletionStages.join(passivationManager.passivateAllAsync());
        WaitNonBlockingStore<UUID, ServerEventImpl> sfs = TestingUtil.getFirstStoreWait(cache);
        int numSegments = cache.getCacheConfiguration().clustering().hash().numSegments();
        assertEquals(1, sfs.sizeWait(IntSets.immutableRangeSet(numSegments)));
    });
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) PassivationManager(org.infinispan.eviction.impl.PassivationManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ServerEventLogger(org.infinispan.server.logging.events.ServerEventLogger) EventLogger(org.infinispan.util.logging.events.EventLogger) UUID(java.util.UUID) ServerEventImpl(org.infinispan.server.logging.events.ServerEventImpl) Test(org.junit.Test)

Aggregations

PassivationManager (org.infinispan.eviction.impl.PassivationManager)5 PersistenceConfiguration (org.infinispan.configuration.cache.PersistenceConfiguration)2 ImmortalCacheEntry (org.infinispan.container.entries.ImmortalCacheEntry)2 PersistenceManager (org.infinispan.persistence.manager.PersistenceManager)2 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)2 Test (org.testng.annotations.Test)2 UUID (java.util.UUID)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 ServerEventImpl (org.infinispan.server.logging.events.ServerEventImpl)1 ServerEventLogger (org.infinispan.server.logging.events.ServerEventLogger)1 EventLogger (org.infinispan.util.logging.events.EventLogger)1 Test (org.junit.Test)1