Nicholas DiPiazza
Nicholas DiPiazza

Reputation: 10595

Can infinispan passivation be used along with memory based eviction?

Using

Is it possible to use passivation and memory based evictions with infinispan?

When I try to use this configuration:

ConfigurationBuilder config = new ConfigurationBuilder();
config.clustering().cacheMode(CacheMode.DIST_SYNC);
config.eviction()
    .type(EvictionType.MEMORY) 
    .size(heapAllocationForCache);
config.persistence().passivation(true)
        .addSingleFileStore()
        .location("/path/to/cache-dir")
        .purgeOnStartup(true);

When I try this configuration I get this error:

2019-10-30 11:28:59 INFO [] EvictionConfigurationBuilder:114 - ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

Here is the validation logic:

if (!strategy.isEnabled()) {
   if (maxEntries > 0) {
      strategy(EvictionStrategy.LIRS);
      log.debugf("Max entries configured (%d) without eviction strategy. Eviction strategy overriden to %s", maxEntries, strategy);
   } else if (getBuilder().persistence().passivation() && strategy != EvictionStrategy.MANUAL) {
      log.passivationWithoutEviction(); // <--------- this line is where the warning comes from
   }
}

Can you not use memory based eviction with Passivation? Or is this a bug with the validation on Infinispan 8.2.x?

Note we cannot set

strategy(EvictionStrategy.LRU) etc because of this code:

https://github.com/infinispan/infinispan/blob/8.2.11.Final/core/src/main/java/org/infinispan/configuration/cache/EvictionConfigurationBuilder.java

if (strategy.isEnabled() && maxEntries <= 0)
         throw new CacheConfigurationException("Eviction maxEntries value cannot be less than or equal to zero if eviction is enabled");

Upvotes: 0

Views: 707

Answers (2)

wfink
wfink

Reputation: 357

As you use EAP the I would not use the Infinispan bits inside of EAP as this are not meant to be used for application cache - also you can not update the version as this is not supported. Best approach is to use RHDG as a supported product or (if you can't) use the latest Infinispan version to have a full feature set and the latest fixes. Also with 9.x yuo can use off-heap memory which provide often a better performance.

See this post for more details Unable to use Infinispan embedded cachemanager on JBoss EAP 7.2

Upvotes: 1

Mudokonman
Mudokonman

Reputation: 901

You should be able to. The problem though is that in 8.2 the default strategy is NONE [1]. Setting the strategy to LIRS or LRU should fix your issue. Newer versions of Infinispan this setting is no longer required unless you want to set it to MANUAL eviction strategy.

config.eviction()
   .type(EvictionType.MEMORY)
   .strategy(EvictionStrategy.LRU) 
   .size(heapAllocationForCache);

[1] https://github.com/infinispan/infinispan/blob/8.2.x/core/src/main/java/org/infinispan/configuration/cache/EvictionConfiguration.java#L19

Upvotes: 0

Related Questions