1 2 Previous Next 15 Replies Latest reply on Sep 6, 2006 10:47 AM by Brian Stansberry

    maxNodes in region question

    Jose Angel Chico Newbie

      Hello everybody.

      I have a little doubt. I have defined the following region:

      region name="/test"
      maxNodes=3
      timeToLiveSeconds=0

      I have no CacheLoader.

      So I suppose that if I insert nodes A, B, C, and D in region "/test", the node A will be evicted (LRU) and the cache will have nodes B, C and D, but in my tests all the nodes A, B, C and D persists in the cache. With others caches with the LRU politic, node A (older) would be deleted.

      Is the paramater "timeToLiveSeconds" with the value "0" what makes the nodes lives forever and not to be evicted?

      Is it possible to have only 3 nodes and the older to be evicted when I insert a new one (with no "timeToLiveSecond" parameter)?

      I need only to have stored the last 50 entries (by example), and to evict/delete the older one (last accesed in time) when I insert a new node.

      What I'm making wrong?

      Sorry but this silly question, but I have been working with SwarmCache (Claudius branch) and with LRU policy, and now we want to migrate to JBossCache and have to mantain this behaviour, and I presume I'm missing something although I have read the docs.

      Thanks in advance. Best regards.

      Jose Angel Chico

        • 1. Re: maxNodes in region question
          Jose Angel Chico Newbie

          Sorry, I forgot to comment that I'm using TreeCache not TreeCacheAOP, with JBossCache-1.2.4_beta version.

          Best Regards.

          Jose Angel Chico

          • 2. Re: maxNodes in region question
            Manik Surtani Master

            timeToLiveSeconds or maxAgeSeconds should be set (and should not be 0) otherwise the LRU policy will not evict anything.

            • 3. Re: maxNodes in region question
              Jose Angel Chico Newbie

              Hello Manik, thanks for the answer.

              I was wrong :( . I have downloaded the sources via the CVS repository and after have a look inside the code I have understand how the LRU (and the cache) algorithm works .

              My error was suppose that the data in the Map inside a node was evicted too. I have seen a JIRA feature request (JBCACHE-76 / JBCACHE-77) that will do this, am I right?

              Thanks again and sorry.

              Best regards.

              Jose Angel Chico

              • 4. Re: maxNodes in region question
                Manik Surtani Master

                Yes, JBCACHE-77 will fix it - right now only nodes are considered and not the data within the nodes.

                • 5. Re: maxNodes in region question
                  Jose Angel Chico Newbie

                  Hello Manik.

                  Only one little detail. We have been making more testing and we have detected a possible bug.

                  The parameter MaxAgeSeconds from LRUPolicy is not assigned to the Region in the method

                  public void configure(TreeCache cache).

                  The code from JBossCache_1_2_4 branch, LRUPolicy.java is the following:

                  public void configure(TreeCache cache) {
                   cache_ = cache;
                   // Step x. Get the config elem
                   Element elem = cache.getEvictionPolicyConfig();
                   parseConfig(elem);
                   // Step x. Create LRUAlgorithm and regions
                   // Step x. Create regions
                   regionManager_ = new RegionManager(this);
                   for(int i=0; i< regionValues_.length; i++) {
                   EvictionAlgorithm algo = getEvictionAlgorithm();
                   try {
                   Region region = regionManager_.createRegion(regionValues_&#91;i&#93;.name_, algo);
                   region.setMaxNodes(regionValues_&#91;i&#93;.maxNodes_ );
                   region.setTimeToLiveSeconds(regionValues_&#91;i&#93;.timeToLiveSeconds_);
                   } catch (RegionNameConflictException e) {
                   throw new RuntimeException(
                   "LRUPolicy.cacheStarted(): illegal region name specified for eviction policy "
                   + " exception: " +e);
                   }
                   }
                  }
                  


                  and we suppose it should be

                  public void configure(TreeCache cache) {
                   cache_ = cache;
                   // Step x. Get the config elem
                   Element elem = cache.getEvictionPolicyConfig();
                   parseConfig(elem);
                   // Step x. Create LRUAlgorithm and regions
                   // Step x. Create regions
                   regionManager_ = new RegionManager(this);
                   for(int i=0; i< regionValues_.length; i++) {
                   EvictionAlgorithm algo = getEvictionAlgorithm();
                   try {
                   Region region = regionManager_.createRegion(regionValues_&#91;i&#93;.name_, algo);
                   region.setMaxNodes(regionValues_&#91;i&#93;.maxNodes_ );
                   region.setTimeToLiveSeconds(regionValues_&#91;i&#93;.timeToLiveSeconds_); region.setMaxAgeSeconds(regionValues_&#91;i&#93;.maxAgeSeconds_); } catch (RegionNameConflictException e) {
                   throw new RuntimeException(
                   "LRUPolicy.cacheStarted(): illegal region name specified for eviction policy "
                   + " exception: " +e);
                   }
                   }
                  }
                  


                  We have been making tests with this change in the code and it works correctly.

                  Best regards.

                  Jose Angel Chico

                  • 6. Re: maxNodes in region question
                    Ben Wang Master

                    maxAgeSeconds has been deprecated since 1.2. If you read the doc, it is not mentioned anymore. Instead, we use timeToLiveSeconds now.

                    -Ben

                    • 7. Re: maxNodes in region question
                      Jose Angel Chico Newbie

                      Ooops!!! Sorry again.

                      We haven't realized it was deprecated. We are using the online doc 'JBossCache Reference Manual' from 1.2.4 Beta, and in this document the parameter 'MaxAgeSeconds' is documented. In the 1.2 Production doc it isn't :(

                      We are making a lot of tests in order to migrate our old cache (SwarmCache) to JBossCache. The 'MaxAgeSeconds' was an interesting parameter for us.

                      But if it was deprecated, we prefer not to use it.

                      Thanks for your quick answer.

                      Best regards.

                      Jose Angel Chico

                      • 8. Re: maxNodes in region question
                        Brian Stansberry Master

                        Thanks for pointing this out. I've removed the reference to maxAgeSeconds from the docs for 1.2.4. final.

                        • 9. Re: maxNodes in region question
                          lordbritish Newbie

                          I think maxAgeSeconds should be put back.

                          I think it's useful to have elements evicted after a certain amount of time no matter how many times it was accessed.

                          Why was this removed?

                          I doesn't seem to be working in the JBossCache version that I have so it appears it's functionality has also been pulled.

                          • 10. Re: maxNodes in region question
                            Ben Wang Master

                            Yes, you are right. I think I stated incorrectly. The parameter that got deprecated is timeToIdleSeconds.

                            maxAgeSeconds was a patch contributed by a user, if I remember it correctly. I will fix it in 1.2.4.

                            Thanks for pointing it out,

                            -Ben

                            • 11. Re: maxNodes in region question
                              lordbritish Newbie

                              I'm using the JBoss Cache fro JBoss AS 4.0.2.

                              So it appears that timeToIdleSeconds is working (but deprecated) and maxAgeSeconds is NOT working and NOT deprecated.

                              Is that correct?

                              LOL.

                              • 12. Re: maxNodes in region question
                                Ben Wang Master

                                Yes, you need more confusion? :-)

                                Btw, maxAgeSeconds issue should be fixed in 1.2.4.

                                -Ben

                                • 13. Re: maxNodes in region question
                                  Mike Cev Newbie

                                   

                                  "manik.surtani@jboss.com" wrote:
                                  Yes, JBCACHE-77 will fix it - right now only nodes are considered and not the data within the nodes.


                                  If this is fixed does it require different configuration? Because I have tested this with my existing config with LRUPolich and maxNones set to 2. Unfortunalty I was able to insert 5 elemnts to that node.
                                  fqn: /definition/extrainfo key: object1
                                  fqn: /definition/extrainfo key: object2
                                  fqn: /definition/extrainfo key: object3
                                  fqn: /definition/extrainfo key: object4
                                  fqn: /definition/extrainfo key: object5

                                  • 14. Re: maxNodes in region question
                                    Manik Surtani Master

                                    That is just one node with 5 data keys in it.

                                    1 2 Previous Next