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