[jboss-user] [JBoss Cache: Core Edition] - Re: Eviction problems: Thread executing before specified tim

andresp21 do-not-reply at jboss.com
Wed Jul 22 11:57:06 EDT 2009


Hi Galder, 

First of all, thank you for your response.

1) Client code

public static void main(String[] args) throws Exception {
  | 		
  | 		CacheFactory factory = new DefaultCacheFactory();
  | 		Cache cache = factory.createCache("cache-config.xml");
  | 		Node rootNode = cache.getRoot();
  | 		
  | 		//1. Add 5 objects to cache:
  | 		
  | 		for(int i=1;i<=5;i++){
  | 			
  | 			Fqn fqn = Fqn.fromString("/user/"+i);
  | 			Node node = rootNode.addChild(fqn);
  | 			node.put("id", ""+i);
  | 		}
  | 		
  | 		while(true){
  | 			
  | 			//2. Query the first 3 objects so that they become the most recently used. This way the remaining 2 nodes would be evicted
  | 			for(int i=1;i<=3;i++){
  | 				Fqn fqn = Fqn.fromString("/user/"+i);
  | 				Node node = cache.getNode(fqn);
  | 			}
  | 			
  | 			//3. Try to put 2 new. 
  | 			for(int i=0;i<2;i++){
  | 				double random = Math.random();
  | 				Fqn fqn = Fqn.fromString("/user/"+random);
  | 				Node node = rootNode.addChild(fqn);
  | 				node.put("id", "" + random);	
  | 			}
  | 			
  | 			//4. Print cache:
  | 			System.out.println(cache.getChildrenNames("/user/"));
  | 			
  | 			
  | 			//5. Sleep for some secs to visualize console
  | 			Thread.currentThread().sleep(2000);
  | 			
  | 		}

2) xml config

<?xml version="1.0" encoding="UTF-8"?>
  | <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
  | 
  | <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
  | 
  |    <eviction wakeUpInterval="
  | 10000
  | ">
  |       
  |       <default algorithmClass="org.jboss.cache.eviction.
  | LRUAlgorithm
  | " eventQueueSize="200000">
  |          <property name="maxNodes" value="5000" />
  |          <property name="timeToLive" value="1000000" />
  |       </default>
  | 
  |       <region name="/user">
  |          <property name="maxNodes" value="5" />
  |          <property name="timeToLive" value="1000" />
  |       </region>
  |      
  |    </eviction>
  | </jbosscache>	

3) Expected behavior:

Given that the specified max number of nodes equals 5, and only 3 of them are queried, I expect that the remaining 2 (the ones that are not queried) are evicted (given the LRU policy). However, I've identified the following problems when looking into the console:

1) 2 of the 3 queried nodes are evicted (this means, 2 of the 3 most recent nodes were evicted)
2) The cache size exceeds the specified constraint (it has more than 5 elements after several iterations of the cycle)
3) The eviction therad is always executed every wakeUpInterval/2


Thank you very much for your time, I'll be eagerly waiting for your response.


Greetings,

Andres Pachon




View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4245359#4245359

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4245359



More information about the jboss-user mailing list