@Override public Collection<CapabilityServiceConfigurator> getDeploymentServiceConfigurators(final ServiceName name) { String cacheName = getCacheName(name, this.name); String containerName = this.config.getContainerName(); String templateCacheName = this.config.getCacheName(); // Ensure eviction and expiration are disabled @SuppressWarnings("deprecation") Consumer<ConfigurationBuilder> configurator = builder -> { // Ensure expiration is not enabled on cache ExpirationConfiguration expiration = builder.expiration().create(); if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) { builder.expiration().lifespan(-1).maxIdle(-1); InfinispanEjbLogger.ROOT_LOGGER.expirationDisabled(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, templateCacheName)); } int size = this.config.getMaxSize(); EvictionStrategy strategy = (size > 0) ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL; builder.memory().evictionStrategy(strategy).evictionType(EvictionType.COUNT).storageType(StorageType.OBJECT).size(size); if (strategy.isEnabled()) { // Only evict bean group entries // We will cascade eviction to the associated beans builder.dataContainer().dataContainer(EvictableDataContainer.createDataContainer(builder, size, BeanGroupKey.class::isInstance)); } }; List<CapabilityServiceConfigurator> builders = new ArrayList<>(3); builders.add(new TemplateConfigurationServiceConfigurator(ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, cacheName)), containerName, cacheName, templateCacheName, configurator)); builders.add(new CacheServiceConfigurator<>(ServiceName.parse(InfinispanCacheRequirement.CACHE.resolve(containerName, cacheName)), containerName, cacheName).require(new ServiceDependency(name.append("marshalling")))); builders.add(new ServiceConfiguratorAdapter(new RemoveOnCancelScheduledExecutorServiceConfigurator(name.append(this.name, "expiration"), EXPIRATION_THREAD_FACTORY))); return builders; }
@Override public void call() { Configuration wildcache1 = cm.getCacheConfiguration("wildcache1"); assertNotNull(wildcache1); assertEquals(10500, wildcache1.expiration().wakeUpInterval()); assertEquals(11, wildcache1.expiration().lifespan()); assertEquals(11, wildcache1.expiration().maxIdle()); }
@Managed @ManagedName("MaxIdle") @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. " + "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.") public long getMaxIdle() { return cache.getCacheConfiguration().expiration().maxIdle(); }
Configuration cacheCfg = cache.getCacheConfiguration(); assertEquals(EvictionType.COUNT, cacheCfg.memory().evictionType()); assertEquals(3000, cacheCfg.expiration().wakeUpInterval()); assertEquals(30000, cacheCfg.memory().size()); assertEquals(100000, cacheCfg.expiration().maxIdle()); cacheCfg = cache.getCacheConfiguration(); assertEquals(EvictionType.COUNT, cacheCfg.memory().evictionType()); assertEquals(3500, cacheCfg.expiration().wakeUpInterval()); assertEquals(35000, cacheCfg.memory().size()); assertEquals(100000, cacheCfg.expiration().maxIdle()); } finally { factory.stop();
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
assertEquals(10000, localTemplate.expiration().wakeUpInterval()); assertEquals(11000, localConfiguration.expiration().wakeUpInterval()); assertEquals(10, localTemplate.expiration().lifespan()); assertEquals(10, localConfiguration.expiration().lifespan());
@ManagedName("Lifespan") @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide." + " -1 means the entries never expire.") public long getLiveTime() { return cache.getCacheConfiguration().expiration().lifespan(); }
compareAttributeSets(name, configurationBefore.compatibility().attributes(), configurationAfter.compatibility().attributes(), "marshaller"); compareAttributeSets(name, configurationBefore.memory().attributes(), configurationAfter.memory().attributes()); compareAttributeSets(name, configurationBefore.expiration().attributes(), configurationAfter.expiration().attributes()); compareAttributeSets(name, configurationBefore.indexing().attributes(), configurationAfter.indexing().attributes()); compareAttributeSets(name, configurationBefore.locking().attributes(), configurationAfter.locking().attributes());
public void testJCacheManagerWithWildcardCacheConfigurations() throws Exception { URI uri = JCacheConfigurationTest.class.getClassLoader().getResource("infinispan_uri.xml").toURI(); withCachingProvider(provider -> { JCacheManager jCacheManager = new JCacheManager( uri, provider.getClass().getClassLoader(), provider, null); Cache<Object, Object> wildcache1 = jCacheManager.createCache("wildcache1", new MutableConfiguration<>()); org.infinispan.Cache unwrap = wildcache1.unwrap(org.infinispan.Cache.class); Configuration configuration = unwrap.getCacheConfiguration(); assertEquals(10500, configuration.expiration().wakeUpInterval()); assertEquals(11, configuration.expiration().lifespan()); assertEquals(11, configuration.expiration().maxIdle()); }); }
@Managed @ManagedName("MaxIdle") @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. " + "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.") public long getMaxIdle() { return cache.getCacheConfiguration().expiration().maxIdle(); }
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
@ManagedName("Lifespan") @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide." + " -1 means the entries never expire.") public long getLiveTime() { return cache.getCacheConfiguration().expiration().lifespan(); }
assertEquals(EvictionType.COUNT, personOverride.memory().evictionType()); assertEquals(5000, personOverride.memory().size()); assertEquals(2000, personOverride.expiration().wakeUpInterval()); assertEquals(60000, personOverride.expiration().lifespan()); assertEquals(30000, personOverride.expiration().maxIdle()); assertEquals(120000, addressesOverride.expiration().lifespan()); assertEquals(60000, addressesOverride.expiration().maxIdle()); assertEquals(EvictionType.COUNT, queryOverride.memory().evictionType()); assertEquals(10000, queryOverride.memory().size()); assertEquals(3000, queryOverride.expiration().wakeUpInterval()); } finally { factory.stop();
@Test public void testCustomPendingPutsCache() { Properties p = createProperties(); p.setProperty(INFINISPAN_CONFIG_RESOURCE_PROP, "alternative-infinispan-configs.xml"); TestRegionFactory factory = createRegionFactory(p); try { Configuration ppConfig = factory.getCacheManager().getCacheConfiguration(DEF_PENDING_PUTS_RESOURCE); assertEquals(120000, ppConfig.expiration().maxIdle()); } finally { factory.stop(); } }
@Managed @ManagedName("WakeUpInterval") @ManagedDescription("Interval between subsequent eviction runs. If you wish to disable the periodic eviction " + "process altogether, set wakeupInterval to -1.") public long getWakeUpInterval() { return cache.getCacheConfiguration().expiration().wakeUpInterval(); }
cacheLifespanOfLeafNodes = configFromXml.expiration().lifespan(); configBuilder.expiration().lifespan(-1); log.debug("Expiration of structure cache entries is disabled. Leaf nodes will use expiration "
@Test public void testBuildEntityRegionPersonPlusEntityOverridesWithoutCfg() { final String person = "com.acme.Person"; Properties p = createProperties(); // Third option, no cache defined for entity and overrides for generic entity data type and entity itself. p.setProperty("hibernate.cache.infinispan.com.acme.Person.memory.eviction.type", "MEMORY"); p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000"); p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000"); p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache"); p.setProperty("hibernate.cache.infinispan.entity.memory.eviction.type", "FIFO"); p.setProperty("hibernate.cache.infinispan.entity.memory.size", "10000"); p.setProperty("hibernate.cache.infinispan.entity.expiration.wake_up_interval", "3000"); TestRegionFactory factory = createRegionFactory(p); try { factory.getCacheManager(); assertFalse( isDefinedCache(factory, person ) ); InfinispanBaseRegion region = factory.buildEntityRegion(person, AccessType.TRANSACTIONAL); assertTrue( isDefinedCache(factory, person ) ); AdvancedCache cache = region.getCache(); Configuration cacheCfg = cache.getCacheConfiguration(); assertEquals(EvictionType.COUNT, cacheCfg.memory().evictionType()); assertEquals(3000, cacheCfg.expiration().wakeUpInterval()); assertEquals(10000, cacheCfg.memory().size()); assertEquals(60000, cacheCfg.expiration().lifespan()); assertEquals(30000, cacheCfg.expiration().maxIdle()); } finally { factory.stop(); } }
/** * Base transactional region constructor * @param cache instance to store transactional data * @param name of the transactional region * @param transactionManager * @param metadata for the transactional region * @param factory for the transactional region * @param cacheKeysFactory factory for cache keys */ public BaseTransactionalDataRegion( AdvancedCache cache, String name, TransactionManager transactionManager, CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) { super( cache, name, transactionManager, factory); this.metadata = metadata; this.cacheKeysFactory = cacheKeysFactory; localCache = cache.withFlags(Flag.CACHE_MODE_LOCAL); Configuration configuration = cache.getCacheConfiguration(); requiresTransaction = configuration.transaction().transactionMode().isTransactional() && !configuration.transaction().autoCommit(); tombstoneExpiration = factory.getPendingPutsCacheConfiguration().expiration().maxIdle(); if (!isRegionAccessStrategyEnabled()) { strategy = Strategy.NONE; } expiringMetaParam = new MetaParam.MetaLifespan(tombstoneExpiration); }