7 Replies Latest reply on May 1, 2004 10:07 AM by Ben Wang

    regionManager question

    cwampler Newbie

      I have been playing around with the new cache eviction features (Kudos by the way, very nicely done), but I have a question.

      I have successfully been able to set up regions and their eviction properties using an xml file then loaded this into the cache using PropertyConfigurator. I have also been playing around with manually creating Regions and RegionManagers and setting up eviction policies that way. However I am unable to figure out how to then feed this RegionManager into the cache.

      What am I not seeing, and is there a tutorial/example of how to do this?

      Thanks,
      Chris


        • 1. Re: regionManager question
          Ben Wang Master

          Hi,

          Thanks for the comment. Currently, "Region" is supported only within LRUPolicy right now (although we will expand that in the next release).

          So you don't use Region and RegionManager directly.

          Hope this answer your question,

          -Ben

          • 2. Re: regionManager question
            cwampler Newbie

            I understand, and thank you for the swiftness of your reply.

            My question then becomes is there a way to dynamically set the timeouts of nodes without using the xml and PropertyConfigurator? Basically a function like this:
            int timeOutInSeconds = 60;
            cache.setNodeTimeout("/a/b", timeOutInSeconds);

            • 3. Re: regionManager question
              Ben Wang Master

              No, we don't support dynamic configuration of eviction policy per node.

              If you want to customize the static node behavior, then you can define "Region" to be a finer granualirty. Will this not meet your need?

              Thanks,

              -Ben

              • 4. Re: regionManager question
                cwampler Newbie

                I see, so let's say I wanted to use the LRUAlgorithm on node "/a" of my cache to give it a 10 second timeout. In such a case I would declare a regionManager to have my LRUPolicy, grab a region from the manager with a node "/a" and the LRUAlgorithm and set the region timeout. As follows:

                cache=new TreeCache(group_name, props, 3000);
                // .. instantiate cache code...
                cache.start();
                LRUAlgorithm algo = new LRUAlgorithm();
                LRUPolicy policy = new LRUPolicy();
                RegionManager regionManager = new RegionManager(policy);
                Region region = regionManager.createRegion("/a", algo);
                region.setTimeToIdleSeconds(10);

                My question is then how to tie this back into the cache. The treecache has cache.setEvictionPolicyClass(String policy_class), but then how does it know about the region?

                Thanks a lot for your patience, and any sample code that could be provided would be greatly appreciated.

                • 5. Re: regionManager question
                  Ben Wang Master

                  No, you can't do it programmatically is what I am saying. But you can do it inside the config xml file, e.g., you specify a region "/a" in there and the TimeToIdleSeconds parameters.


                  -Ben

                  • 6. Re: regionManager question
                    rajd Newbie

                    Can't I get the get the region from the RegionManager given the FQN string and then for that region set the idle time ( Assuming that there is only one node in that region)

                    Thnx,
                    - Raj

                    • 7. Re: regionManager question
                      Ben Wang Master

                      What you mentioned is doable but not possible right now since RegionManager is not a singleton so user can't obtain the reference directly to mainupulate the eviction policy config directly. But I may consider to provide it in the next major release.

                      Thanks,

                      -Ben