@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; }
if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) { builder.expiration().lifespan(-1).maxIdle(-1); InfinispanWebLogger.ROOT_LOGGER.expirationDisabled(InfinispanCacheRequirement.CONFIGURATION.resolve(this.containerName, templateCacheName));
@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(); }
@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(); }
if (ignoreCache.test(cacheName)) throw new CacheUnavailableException(cacheName); cacheConfiguration = getCacheConfiguration(); defaultLifespanTime = cacheConfiguration.expiration().lifespan(); defaultMaxIdleTime = cacheConfiguration.expiration().maxIdle(); if (endOfOp.get()) {
updateClusterTable(cacheManager.getMembers()); lifespanSpinner.setValue(cache.getCacheConfiguration().expiration().lifespan()); maxIdleSpinner.setValue(cache.getCacheConfiguration().expiration().maxIdle()); cacheContentsSizeLabel.setText("Cache contains " + cache.size() + " entries");
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()); }); }
@Override public Collection<CapabilityServiceConfigurator> getDeploymentServiceConfigurators(final ServiceName name) { String cacheName = getCacheName(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<>(4); 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; }
private static Cache<?, ?> checkValidConfiguration(final Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.expiration().maxIdle() != -1) { throw log.luceneStorageHavingIdleTimeSet(indexName, cache.getName()); } if (configuration.expiration().lifespan() != -1) { throw log.luceneStorageHavingLifespanSet(indexName, cache.getName()); } if (configuration.memory().storageType() == StorageType.BINARY) { throw log.luceneStorageAsBinaryEnabled(indexName, cache.getName()); } if (!Configurations.noDataLossOnJoiner(configuration)) { throw log.luceneStorageNoStateTransferEnabled(indexName, cache.getName()); } return cache; }
private static Cache<?, ?> checkValidConfiguration(final Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.expiration().maxIdle() != -1) { throw log.luceneStorageHavingIdleTimeSet(indexName, cache.getName()); } if (configuration.expiration().lifespan() != -1) { throw log.luceneStorageHavingLifespanSet(indexName, cache.getName()); } if (configuration.memory().storageType() == StorageType.BINARY) { throw log.luceneStorageAsBinaryEnabled(indexName, cache.getName()); } if (!Configurations.noDataLossOnJoiner(configuration)) { throw log.luceneStorageNoStateTransferEnabled(indexName, cache.getName()); } return cache; }
@Override protected void startInternal(MemcachedServerConfiguration configuration, EmbeddedCacheManager cacheManager) { if (cacheManager.getCacheConfiguration(configuration.defaultCacheName()) == null) { // Define the Memcached cache as clone of the default one cacheManager.defineConfiguration(configuration.defaultCacheName(), new ConfigurationBuilder().read(cacheManager.getDefaultCacheConfiguration()).build()); } ExpirationConfiguration expConfig = cacheManager.getCacheConfiguration(configuration.defaultCacheName()).expiration(); if (expConfig.lifespan() >= 0 || expConfig.maxIdle() >= 0) throw log.invalidExpiration(configuration.defaultCacheName()); Cache<byte[], byte[]> cache = cacheManager.getCache(configuration.defaultCacheName()); memcachedCache = cache.getAdvancedCache(); super.startInternal(configuration, cacheManager); }
private static Cache<?, ?> checkValidConfiguration(final Cache<?, ?> cache, String indexName) { if (cache == null) { return null; } Configuration configuration = cache.getCacheConfiguration(); if (configuration.expiration().maxIdle() != -1) { throw log.luceneStorageHavingIdleTimeSet(indexName, cache.getName()); } if (configuration.expiration().lifespan() != -1) { throw log.luceneStorageHavingLifespanSet(indexName, cache.getName()); } if (configuration.storeAsBinary().enabled()) { throw log.luceneStorageAsBinaryEnabled(indexName, cache.getName()); } if (!Configurations.noDataLossOnJoiner(configuration)) { throw log.luceneStorageNoStateTransferEnabled(indexName, cache.getName()); } return cache; }
@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()); }
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());
@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(); } }
cacheLifespanOfLeafNodes = configFromXml.expiration().lifespan(); configBuilder.expiration().lifespan(-1); log.debug("Expiration of structure cache entries is disabled. Leaf nodes will use expiration "
assertEquals(2000, cacheCfg.expiration().wakeUpInterval()); assertEquals(5000, cacheCfg.memory().size()); assertEquals(60000, cacheCfg.expiration().lifespan()); assertEquals(30000, cacheCfg.expiration().maxIdle()); assertFalse(cacheCfg.jmxStatistics().enabled()); assertEquals(2500, cacheCfg.expiration().wakeUpInterval()); assertEquals(5500, cacheCfg.memory().size()); assertEquals(65000, cacheCfg.expiration().lifespan()); assertEquals(35000, cacheCfg.expiration().maxIdle()); assertFalse(cacheCfg.jmxStatistics().enabled());
assertEquals(EvictionType.COUNT, c.memory().evictionType()); assertEquals(StorageType.OBJECT, c.memory().storageType()); assertEquals(60000, c.expiration().lifespan()); assertEquals(1000, c.expiration().maxIdle()); assertEquals(500, c.expiration().wakeUpInterval());
assertEquals(20000, c.memory().size()); assertEquals(10000, c.expiration().wakeUpInterval()); assertEquals(10, c.expiration().lifespan()); assertEquals(10, c.expiration().maxIdle()); assertFalse(c.persistence().passivation()); assertEquals(20500, c.memory().size()); assertEquals(10500, c.expiration().wakeUpInterval()); assertEquals(11, c.expiration().lifespan()); assertEquals(11, c.expiration().maxIdle()); assertEquals(Index.NONE, c.indexing().index()); assertEquals(21000, c.memory().size()); assertEquals(11000, c.expiration().wakeUpInterval()); assertEquals(12, c.expiration().lifespan()); assertEquals(12, c.expiration().maxIdle()); assertFalse(c.clustering().stateTransfer().fetchInMemoryState()); assertEquals(21500, c.memory().size()); assertEquals(11500, c.expiration().wakeUpInterval()); assertEquals(13, c.expiration().lifespan()); assertEquals(13, c.expiration().maxIdle()); assertTrue(c.clustering().stateTransfer().fetchInMemoryState());