This content has been marked as final.
Show 9 replies
-
1. Re: LRUPolicy eviction policy
lovelyliatroim Oct 27, 2008 10:11 AM (in response to lovelyliatroim)Also documentation for this
# timeToLiveSeconds - The amount of time a node is not written to or read (in seconds) before the node is swept away. 0 denotes no limit.
If you leave it out, you get an exception like soorg.jboss.cache.config.ConfigurationException: timeToLiveSeconds must be configured to a value greater than or equal to 0 at org.jboss.cache.eviction.LRUConfiguration.validate(LRUConfiguration.java:85) at org.jboss.cache.factories.XmlConfigurationParser.parseEvictionPolicyConfig(XmlConfigurationParser.java:616)
Docs should possibly state that this is mandatory or let the default value for this be 0 when nothing configured for it.
Just passing on some thoughts on it.
Cheers,
LL -
2. Re: LRUPolicy eviction policy
lovelyliatroim Oct 28, 2008 5:11 AM (in response to lovelyliatroim)Just seen this in the documents
Q. I have set up an eviction region but none of the nodes in that region get evicted.
Make sure that the region starts with the / character, i.e.
<region name="/org/jboss/data" ...
I see that i was missng a "/" at the start in my original post, doesnt make a difference though. After first eviction sweep 3 records are still present. -
3. Re: LRUPolicy eviction policy
manik Oct 29, 2008 10:38 AM (in response to lovelyliatroim)"lovelyliatroim" wrote:
I have done the test on it and looks to me like its based on nodes with data attached, could someone just confirm this for me on how it works.
Have you marked any of these as resident? -
4. Re: LRUPolicy eviction policy
lovelyliatroim Oct 29, 2008 1:13 PM (in response to lovelyliatroim)
Have you marked any of these as resident?
No none marked as resident!!
Will dig out my test case and post, not sure the config is right because i was playing around with different scenarios, will set up properly tomorrow and post it. -
5. Re: LRUPolicy eviction policy
lovelyliatroim Oct 30, 2008 6:23 AM (in response to lovelyliatroim)So here is the config for the test
<region name="/evictiontest/LRU" policyClass="org.jboss.cache.eviction.LRUPolicy"> <attribute name="maxNodes">3</attribute> <attribute name="timeToLiveSeconds">30</attribute> <attribute name="maxAgeSeconds">30</attribute> </region>
My sample test casepublic void evictionTest(String configPath) throws Exception{ CacheFactory factory = DefaultCacheFactory.getInstance(); Cache cache = factory.createCache(configPath); CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(cache); wrapper.create(); wrapper.start(); System.out.println("Cache created"); String lruPath="/evictiontest/LRU/a/b/c"; Fqn lruFQN =Fqn.fromString(lruPath); String expPath="/evictiontest/EXP/a/b/c"; Fqn expFQN =Fqn.fromString(expPath); String key ="data"; HashMap testData = new HashMap(); testData.put("Client", "Bond,James"); cache.put(lruFQN,key, testData); HashMap val = (HashMap)cache.get(lruFQN, key); System.out.println("Value taken from hash "+val.toString()); //Test Max Nodes attribute now and how that works for(int i = 0; i < 10 ;i ++){ lruFQN =Fqn.fromString(lruPath+i); cache.put(lruFQN,key, testData); } System.out.println("Added more nodes than allowed to region " + wrapper.printCacheDetails()); int counter = 0; while(true){ counter = counter + 10; Thread.currentThread().sleep(10000); System.out.println("Slept "+counter +" secs " + wrapper.printCacheDetails()); }
Output that i seeCache created Value taken from hash {Client=Bond,James} Added more nodes than allowed to region / null /evictiontest null /LRU null /a null /b null /c5 {data={Client=Bond,James}} /c6 {data={Client=Bond,James}} /c8 {data={Client=Bond,James}} /c {data={Client=Bond,James}} /c7 {data={Client=Bond,James}} /c9 {data={Client=Bond,James}} /c2 {data={Client=Bond,James}} /c0 {data={Client=Bond,James}} /c1 {data={Client=Bond,James}} /c4 {data={Client=Bond,James}} /c3 {data={Client=Bond,James}} Slept 10 secs / null /evictiontest null /LRU null /a null /b null /c8 {data={Client=Bond,James}} /c7 {data={Client=Bond,James}} /c9 {data={Client=Bond,James}} Slept 20 secs / null /evictiontest null /LRU null /a null /b null /c8 {data={Client=Bond,James}} /c7 {data={Client=Bond,James}} /c9 {data={Client=Bond,James}} Slept 30 secs / null /evictiontest null /LRU null /a null /b null /c8 {data={Client=Bond,James}} /c7 {data={Client=Bond,James}} /c9 {data={Client=Bond,James}} Slept 40 secs / null /evictiontest null /LRU null /a null /b null
Eviction timer thread runs every 3 seconds. So back to the original question, how does maxNodes work?? Its configured as 3, so is that 3 nodes with data below the region or is it 3 nodes regardless of data below the region?? It looks to me like it is nodes with data!! Is this the expected behaviour??
The remaining 3 records get evicted after they have lived their life expectancy of 30 seconds.
By the way this last test was carried out with 3.x version but the original test was done with the 2.x version. -
6. Re: LRUPolicy eviction policy
manik Oct 30, 2008 12:01 PM (in response to lovelyliatroim)I'll let Mircea answer, he's the guy who added the resident node feature. :-)
-
7. Re: LRUPolicy eviction policy
mircea.markus Oct 30, 2008 12:51 PM (in response to lovelyliatroim)Eviction timer thread runs every 3 seconds. So back to the original question, how does maxNodes work??
The general rule is that implicitly created nodes are not being counted for eviction. They are not structural nodes neither (e.g. if you add something to them they will be considered for eviction). -
8. Re: LRUPolicy eviction policy
lovelyliatroim Oct 30, 2008 1:41 PM (in response to lovelyliatroim)
The general rule is that implicitly created nodes are not being counted for eviction. They are not structural nodes neither (e.g. if you add something to them they will be considered for eviction).
Hi Mircea,
Ok I need to brush up on my jboss cache terminology, so correct me if im wrong
Structural Nodes are what you would call resident nodes??? So in this example "/evictiontest/LRU" would be a structural node.
Implicitly created nodes are nodes which are created to make up the tree path to get to the data node so in this example "/a/b" would be implicit nodes.
So in lay man terms, if a node in a region has a data item attached, the maxNodes counter goes up one, if not then the counter stays the same!!
Thanks for your time Mircea,
LL -
9. Re: LRUPolicy eviction policy
angusm Mar 24, 2009 10:31 AM (in response to lovelyliatroim)Mircea (or other),
Is it possible to configure implicitly created nodes so they are evicted?
I have a cache (JBC 303) which will have 100,000 entries, and a depth of 5. So that is, potentially, 400,000 implicitly created nodes hanging around indefinitely (if I have correctly understood).
Thanks, Angus