@Override public ModelNode execute(Cache<?, ?> cache) { ActivationManager manager = cache.getAdvancedCache().getComponentRegistry().getComponent(ActivationManager.class); return new ModelNode((manager != null) ? manager.getActivationCount() : 0); } },
@Override public ModelNode execute(Cache<?, ?> cache) { PassivationManager manager = cache.getAdvancedCache().getComponentRegistry().getComponent(PassivationManager.class); return new ModelNode((manager != null) ? manager.getPassivations() : 0); } },
@SuppressWarnings("deprecation") static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH, RequiredChildResourceDiscardPolicy.NEVER) : InfinispanModel.VERSION_6_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, EVICTION_PATH, RequiredChildResourceDiscardPolicy.NEVER) : parent.addChildResource(PATH); if (InfinispanModel.VERSION_6_0_0.requiresTransformation(version)) { builder.getAttributeBuilder() .addRename(Attribute.SIZE.getDefinition(), DeprecatedAttribute.MAX_ENTRIES.getName()) .setValueConverter(new SimpleAttributeConverter((address, name, value, model, context) -> { // Set legacy eviction strategy to NONE if size is negative, otherwise set to LRU if (model.hasDefined(Attribute.SIZE.getName()) && (model.get(Attribute.SIZE.getName()).asLong() < 0)) { value.set(EvictionStrategy.NONE.name()); } else { value.set(EvictionStrategy.LRU.name()); } }), DeprecatedAttribute.STRATEGY.getDefinition()) .end(); } if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) { builder.getAttributeBuilder().setValueConverter(new SimpleAttributeConverter((address, name, value, model, context) -> { if (value.isDefined()) { value.set(value.asInt()); } }), Attribute.SIZE.getDefinition(), DeprecatedAttribute.MAX_ENTRIES.getDefinition()); } }
@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; }
void evict() { builder.eviction() .strategy(EvictionStrategy.valueOf(options.getString(Caching.CreateOption.EVICTION).toUpperCase())) .maxEntries(options.getInt(Caching.CreateOption.MAX_ENTRIES)); } void expire() {
@Override public void passivateAll() throws PersistenceException { delegate.passivateAll(); }
@Override public boolean isEnabled() { return delegate.isEnabled(); }
@Override public boolean getStatisticsEnabled() { return delegate.getStatisticsEnabled(); }
@Override public void setStatisticsEnabled(boolean enabled) { delegate.setStatisticsEnabled(enabled); }
@Override public void resetStatistics() { delegate.resetStatistics(); } }
@Override public void skipPassivationOnStop(boolean skip) { delegate.skipPassivationOnStop(skip); }
@Override public void passivate(InternalCacheEntry entry) { final Runnable before = beforePassivate; if (before != null) { before.run(); } delegate.passivate(entry); final Runnable after = afterPassivate; if (after != null) { after.run(); } }
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); doNothing().when(activationManager).onUpdate(Mockito.any(), Mockito.anyBoolean()); InternalExpirationManager expirationManager = mock(InternalExpirationManager.class); Mockito.when(expirationManager.entryExpiredInMemory(Mockito.any(), Mockito.anyLong(), Mockito.anyBoolean())).thenReturn(CompletableFutures.completedTrue()); Mockito.when(expirationManager.entryExpiredInMemoryFromIteration(Mockito.any(), Mockito.anyLong())).thenReturn(CompletableFutures.completedTrue()); TestingUtil.inject(dc, internalEntryFactory, activationManager, timeService, expirationManager); return dc; }
EvictionStrategy strategy = (size > 0) ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL; builder.memory().evictionStrategy(strategy).evictionType(EvictionType.COUNT).storageType(StorageType.OBJECT).size(size); if (strategy.isEnabled()) {
@Override public long getPassivations() { return delegate.getPassivations(); }
@Override public ModelNode execute(Cache<?, ?> cache) { ActivationManager manager = cache.getAdvancedCache().getComponentRegistry().getComponent(ActivationManager.class); return new ModelNode((manager != null) ? manager.getActivationCount() : 0); } },
@Override public Void run() { PassivationManager passivationManager = cache.getComponentRegistry().getComponent(PassivationManager.class); if (passivationManager != null) { passivationManager.passivateAll(); } return null; } }
private static void verifyCacheHasNoEviction(AdvancedCache<?, ?> cache) { if (cache.getCacheConfiguration().eviction().strategy().isEnabled()) throw new IllegalArgumentException("DistributedSegmentReadLocker is not reliable when using a cache with eviction enabled, disable eviction on this cache instance"); }
@Override public ModelNode execute(Cache<?, ?> cache) { PassivationManager manager = cache.getAdvancedCache().getComponentRegistry().getComponent(PassivationManager.class); return new ModelNode((manager != null) ? manager.getPassivations() : 0); } },
private static void validateMetadataCache(Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.eviction().strategy().isEnabled()) { throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName()); } if (configuration.persistence().usingStores() && !configuration.persistence().preload()) { throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName()); } }