5 Replies Latest reply on Sep 2, 2008 4:57 PM by Laurent Mimoun

    Problem with expiration eviction

    Laurent Mimoun Newbie


      I wrote the following code to use expiration eviction policy :

      Region region = admDataCache.getRegion(fqn, true);
       ExpirationConfiguration expirationConfiguration = new ExpirationConfiguration();
       admDataCache.getRoot().put(fqn, objectToCache);

      But my cached objects never expire.

      My cache-configuration doesn't contain any eviction property :

      <?xml version="1.0" encoding="UTF-8"?>
       <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
       <attribute name="IsolationLevel">SERIALIZABLE</attribute>
       <attribute name="CacheMode">INVALIDATION_SYNC</attribute>
       <attribute name="ClusterName">Cluster-Of-Controllers</attribute>
       <attribute name="ClusterConfig">
       <TCP start_port="7800" loopback="true"/>
       <MPING timeout="3000" bind_to_all_interfaces="false"
       mcast_addr="" mcast_port="7500" ip_ttl="0"
       num_initial_members="2" />
       <MERGE2 max_interval="20000" min_interval="10000" />
       <FD_SOCK />
       <VERIFY_SUSPECT timeout="1500"/>
       <pbcast.NAKACK gc_lag="50" max_xmit_size="8192" retransmit_timeout="600,1200,2400,4800" />
       <UNICAST timeout="600,1200,2400"/>
       <pbcast.STABLE desired_avg_gossip="20000" />
       <pbcast.GMS join_retry_timeout="2000" join_timeout="5000" print_local_addr="false" shun="true" />
       <pbcast.STATE_TRANSFER />
       <attribute name="FetchStateOnStartup">false</attribute>
       <attribute name="InitialStateRetrievalTimeout">5000</attribute>
       <attribute name="LockAcquisitionTimeout">15000</attribute>
       <attribute name="UseMarshalling">false</attribute>
       <attribute name="CacheLoaderShared">true</attribute>
       <attribute name="CacheLoaderPreload">/</attribute>
       <attribute name="CacheLoaderPassivation">false</attribute>
       <attribute name="CacheLoaderFetchPersistentState">false</attribute>
       <attribute name="CacheLoaderFetchTransientState">false</attribute>
       <attribute name="CacheLoaderAsynchronous">false</attribute>

      Could you tell to me why my code doesn't work ?


        • 1. Re: Problem with expiration eviction
          J B Novice

          Have a read here


          Looks to me that your missing the equivalent of this

          // sets the expiry time for a node
          cache.getRoot().addChild(fqn1).put(ExpirationConfiguration.EXPIRATION_KEY, future);

          You have add to set the EXPIRATION_KEY on the node as well as your data item that your caching!!

          • 2. Re: Problem with expiration eviction
            Mircea Markus Master

            If you want to specify the eviction melodramatically only (no eviction config in the xml file), you have to do it like this:

            ExpirationConfiguration expirationConfiguration = new ExpirationConfiguration();
             EvictionConfig ec = new EvictionConfig();
             List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
             EvictionRegionConfig erc = new EvictionRegionConfig(fqn, expirationConfiguration);

            This is a bug, and the workaround is to set EXPIRATION_KEY for all elements, as lovelyliatroim suggested.
            https://jira.jboss.org/jira/browse/JBCACHE-1399 was created

            • 3. Re: Problem with expiration eviction
              Laurent Mimoun Newbie

              Ok thx to all. In fact I removed the expiration configuration in the config file and the code. I just added the line suggested by lovelyliatroim and it sounds to work fine I just have warnings in the log file about the different nodes of the FQN where I add my object :

              2008-09-01 11:01:25,709: WARN [EvictionTimer-0] ExpirationAlgorithm, org.jboss.cache.eviction.ExpirationAlgorithm: No expiration key 'expiration' for Node: /node1
              2008-09-01 11:01:25,712: WARN [EvictionTimer-0] ExpirationAlgorithm, org.jboss.cache.eviction.ExpirationAlgorithm: No expiration key 'expiration' for Node: /node1/node2
              2008-09-01 11:01:25,713: WARN [EvictionTimer-0] ExpirationAlgorithm, org.jboss.cache.eviction.ExpirationAlgorithm: No expiration key 'expiration' for Node: /node1/node2/node3

              Anyway mircea is right, it should work with my previous code and with the fix (in 3.0.0.GA version), it should be surely possible to set the expiration at the root of a tree or subtree without having to do it again on every sub nodes and object.

              Tomorow I will add these additionnal note in the consequently created issue.

              • 4. Re: Problem with expiration eviction
                Laurent Mimoun Newbie

                Oups here is my eviction configuration (I choose the most simple thing ;) ) :

                <attribute name="EvictionPolicyConfig">
                <!-- Name of the DEFAULT eviction policy class. -->
                <attribute name="policyClass">org.jboss.cache.eviction.ExpirationPolicy</attribute>

                • 5. Re: Problem with expiration eviction
                  Laurent Mimoun Newbie


                  <attribute name="EvictionPolicyConfig">
                   <attribute name="policyClass">org.jboss.cache.eviction.ExpirationPolicy</attribute>