5 Replies Latest reply: Jan 5, 2011 11:54 AM by Galder Zamarreño RSS

Infinispan 4.1 and 4.2 eviction error

Samuel Santos Newbie

Hello all,

 

I can't find a proper way to get eviction working with Infinispan 4.1 and 4.2.

Can anyone point me a way to get it working please?

 

Bellow is my Infinispan configuration file which works fine with Infinispan 4.0.

<?xml version="1.0" encoding="UTF-8"?>
<infinispan
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
    xmlns="urn:infinispan:config:4.0">
    <global>
        <transport clusterName="ApplicationCluster">
            <properties>
                <property name="configurationFile" value="jgroups-udp.xml" />
            </properties>
        </transport>
    </global>
    <default>
        <eviction strategy="FIFO" wakeUpInterval="6000" />
    </default>
    <namedCache name="cache1" />
    <namedCache name="cache2" />
    <namedCache name="cache3">
        <eviction strategy="NONE" />
        <expiration lifespan="3000" />
        <clustering mode="distribution">
            <async />
            <hash />
            <l1 lifespan="3000" />
        </clustering>
    </namedCache>
</infinispan>

 

And bellow are the unit tests I use to test both eviction and expiration configurations.

Unfortunatly getCache1 method fails with both Infinispan 4.1 and 4.2.

@Test
public void getCache3() throws InterruptedException {
    Cache<String, String> cache3 = service.getManager().getCache("cache3");
    long expirationLifespan = cache3.getConfiguration().getExpirationLifespan();

    cache3.put("key", "value");

    LOGGER.info("ChartCache expiration lifespan: {}", expirationLifespan);
    LOGGER.info("ChartCache contains key? {}", cache3.containsKey("key"));
    Assert.assertTrue(cache3.containsKey("key"));
    Thread.sleep(expirationLifespan + 500L);
    LOGGER.info("ChartCache contains key? {}", cache3.containsKey("key"));
    Assert.assertFalse(cache3.containsKey("key"));
}

@Test
public void getCache1() throws InterruptedException {
    Cache<String, String> cache1 = service.getManager().getCache("cache1");
    long evictionWakeUpInterval = cache1.getConfiguration().getEvictionWakeUpInterval();

    cache1.put("key", "value");

    LOGGER.info("MenuCache eviction wake up: {}", evictionWakeUpInterval);
    LOGGER.info("MenuCache contains key? {}", cache1.containsKey("key"));
    Assert.assertTrue(cache1.containsKey("key"));
    Thread.sleep(evictionWakeUpInterval + 500L);
    LOGGER.info("MenuCache contains key? {}", cache1.containsKey("key"));
    Assert.assertFalse(cache1.containsKey("key"));
}

 

Thanks.